Skip to content

[bug] $'...' unit between two comsubs in one word is folded to a space (echo A$((1+1))B$'\n'C$((2+2))D prints one line; GNU prints two) #379

Closed

Description

@caomengxuan666

Found by the wt24/adjcomsub lane while fixing #376 (verified pre-existing on the base binary by stash A/B — not introduced or flipped by d1cdb7b).

Reproducer

echo A$((1+1))B$'\n'C$((2+2))D
  • WSL GNU Bash 5.3.0: prints two lines — A2B then C4D (the $'\n' is a real newline).
  • rubash (base and current): prints A2B C4D — the $'\n' between the two $((...)) spans is folded to a single space.

Why it is a separate class from #376

#376 was the whole-word $(( admission mis-slicing bodies (fixed by the real span scanner). This shape has alnum-adjacent material (so the whole-word fast path correctly declines), and the corruption happens in whatever reassembles the word after the embedded walker processes the two arithmetic spans — the ANSI-C $'...' unit between them loses its decoded newline and becomes a space, i.e. it looks like a field-split/join step is being applied to mid-word material that GNU keeps as literal word content (parse.y:5493-5523 read_token_word keeps $'...' as one word unit; subst.c:11229 expand_word_internal decodes it in place, no splitting for quoted/word-internal content).

Probe hint

The lane's stash-A/B probe lives with the #376 artifacts; minimal matrix to carry into the fix lane's regression file: $'\n' / $'\t' / $' ' between two comsubs, between comsub and literal, and standalone echo $'a\nb' (control — believed already correct), quoted and unquoted word positions.

Activity

  1. added 2 commits that reference this issue on Oct 1, 2026
  2. caomengxuan666 commented on Oct 1, 2026

    @caomengxuan666
    MemberAuthor

    Landed as c52a721 (wt29/rubugs lane ffcfe33e). Root cause: once a word's comsub spans put it on the field-split path, the DECODED ANSI-C whitespace was split as expansion-result data; GNU quotes every decoded byte (parse.y:5560-5575) so it is word data. Fix: ANSI_C_IFS_GUARD (U+E401) emitted at the lexer decode bottleneck (inside the existing markers.rs PUA registry; codepoint empirically clear of the comsub payload ranges E001-E100 and the E400 literal-escape registry), converted to IFS_GLUE at split sites and dropped at every value boundary. echo A$((1+1))B$'\n'C$((2+2))D prints two lines like GNU; 11 new tests; 33-suite ledger identical. NOTE for the record: this adds one registry member in the String word domain (not the Vec carrier domain) — flagged for owner review per the TYPED-markers rule. CI green.

  3. added
    bug
    area:parser
    family:S5
    on Oct 17, 2026
  4. added a commit that references this issue on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:parserbugfamily:S5

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions