Skip to content

fix: top-level unclosed procsub continuation, [ ( diagnostic token, bare drive-root POSIX form (#564 #565 #566) - #577

Merged
caomengxuan666 merged 4 commits into
masterfrom
fix/wave4c-parser-path
Oct 13, 2026
Merged

caomengxuan666 merged 4 commits into
masterfrom
fix/wave4c-parser-path

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Three fixes: #564 (top-level unclosed procsub continues across lines - GNU parse.y:5494-5524 shellexp arm, with the #373-adjudicated case/semicolon placements preserved after 4 regressions were caught in full-suite comparison), #565 ([ ( empty-body diagnostic token alignment), #566 (bare drive root /c was falling into map_logical_path - boundary contract B1 violation). Each with vendored-bash anchors and RED-then-GREEN regressions (27 new tests). Contract suite 24 green. Failure parity vs fresh master with positional-artifact analysis.

…d newline naming, bare drive root cd (#564/#565/#566)

#564: GNU read_token (parse.y:3776-3796) declines the `<'/`>' operator when
peek_char == '(' and falls into read_token_word, whose shellexp arm
(parse.y:5494-5524) reads the `(...)` body via parse_comsub (parse.y:4451)
across physical newlines - ONE word token regardless of what precedes the
introducer. rubash's group reader committed the logical line after the
introducer line, so `cat <(echo' NL `echo hi' NL `)' died with `syntax
error near unexpected token `(''. Three pieces: the one-shot unclosed-input
oracle (continuation.rs) and the incremental close-char residual scanner
now push the body's `)' matched pair when an ADJACENT `(' follows the
redirect operator (the K5 tail park covers the buffer edge), the join gate
extends to operator-position bodies via the text-level oracle
line_ends_in_open_operator_process_substitution (the exact complement of
the #463 word-attached gate), and the procsub source reconstruction folds
only STRAY joined newlines back to `\n' (leading, or doubled after `;'/`;;'
- positions where a reconstructed `;' is a syntax error a newline never is)
while mid-body and trailing separators keep the `;' spelling the
#373/#381/#390 adjudication pins (`case esac in ; esac', `echo bye ;').
Acceptance: WSL GNU 5.3.0 `cat <(echo hi\necho hi2\n)' runs BOTH lines and
the script continues, `echo <(echo\necho hi2\n)' still evaluates to
/dev/fd/N; 11 new tests green, 4 RED on fresh master d116874.

#565: the shifted `(' of the function_def production (parse.y:1054 via
read_token's parse.y:3774-3790 classification) is the token stream's LAST
token for a final line without a terminator. GNU's reader still hands yacc
the physical line's NEWLINE and rejects THAT: `syntax error near unexpected
token `newline'' + print_offending_line of the `(' line (parse.y:6814;
WSL GNU probes: `[ (` NL, `f (` NL, `echo (` NL and `bash -c '[ ('` all
name `newline', never `('). The name_override arm now maps that
nothing-after-the-shifted-paren shape to `newline' without touching the
#563 C4b neighbours (two+ words still name the `(' itself). `x=1 (' is
pinned as the #452 adjudication boundary, NOT a GNU cell: rubash accepts
assignment-prefix + subshell (real GNU 5.3.0 rejects even the raw corpus
shapes), so the reader's join stands and clean EOF reports the
`unexpected end of file from `(' command' diagnostic at the EOF line.
Harness: the stdin driver binds argv[0] as the diagnostic program name, so
the file normalizes the exe path to `bash' like the #551 harness. 9 tests
green, 4 RED on fresh master.

#566: boundary contract B1 (docs/windows-path-contract.md L1) accepts the
drive-form operands `/c/...', `/c/', `/c/.', `/D' - but the BARE root `/c'
slipped past shell_path_to_windows_inner's drive arm (len >= 3 with a slash
at byte 2) into the shell-root mapping, where map_logical_path resolved it
to <root>/c -> ENOENT: `cd /c' failed while `cd /c/' worked, and a root
carrying a `d/' directory made `cd /d' work by coincidence. The drive arm
now maps the bare root to the drive root (case-insensitive) and
map_logical_path's drive-form exclusion covers the two-letter spelling;
`cd /c' renders the POSIX `/c/' exactly like its slashed sibling, and a
same-named root child no longer shadows the drive. Contract doc ledger and
the suite's "filed separately" note updated. 7 tests green, 5 RED on fresh
master.
Conflict resolution, src/parser/token_actions.rs: the #563 C4b tuple
classifier and the #565 empty-fnhead newline naming are two cells of the
same '(' error classifier — master's explicit None/Eof arms already
implement the #565 cells, so the merged block keeps master's tuple
structure and carries the #565 rationale comment on the arms that
implement it. C4b acceptance (tests/issue516, 7/7) and the #565 matrix
(6/6) both pass.

Semantic reconciliation, tests/issue565...: the x=1 ( cell followed the
pre-#516 #452 join-and-EOF adjudication; master's #516 re-adjudication
(token error at the paren, GNU p14/p16/p21 + q-series) supersedes it per
the suite-parity rule — the cell now expects the trunk outcome.

Full suite parity vs fresh master @ 32f9260: 43 failed on both sides,
name-identical in both directions; branch additionally passes the 24 new
#564/#565/#566 regression tests.
…licitly

command_prepare.rs's function-call redirect gate calls
finish_heredoc_expansion_error for its exit-code store and drops the
run/continue verdict (shape carried over the 32f9260 base on both
sides, unchanged by the #573 merge). The bare call trips unused_must_use
once the crate builds under RUSTFLAGS=-D warnings; make the discard
explicit. No behavior change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[parser] echo <(echo 顶层未闭 procsub:GNU 跨行续读,rubash 立即报错

1 participant