Repository navigation
lexer: join lines while a word-attached procsub body is open (fixes #463) - #483
Merged
Merged
Conversation
GNU folds `word<(` into the word via read_token's fall-through (parse.y:3793-3797) and read_token_word's shellexp arm (parse.y:5494-5524), with the `(...)` body consumed under parse_matched_pair's LEX_GTLT discipline (parse.y:4147-4153) where newlines are ordinary body characters. rubash's word scanner already spans the body (skip_cmd_subst), but the tokenizer's logical-line join gate had no signal for it, so `echo outer<(` NL `echo inner` NL `)` — and the h4l/json.bash jb-cli `jb menu:json@<(...)' nesting example — died with `syntax error near unexpected token `)'`. - word_ends_in_open_process_substitution (continuation.rs): quote/ escape/backtick-aware scan of the last word token's raw span; answers whether the word ended inside an unclosed word-attached `<(`/`>(`. - GroupScanFeeder join gate (lexer/mod.rs): when the pass's last token is that word, hold the logical line open for the next physical line, clear the tail-resume checkpoint (the pass ended mid-word), and let token_level_needs_more report it so the incremental group reader (script/`-c` execution) keeps appending too. - Bare `<(` (word-initial) is untouched — the parser's own procsub bridge handles it; #424's extglob redirect rejections stay green; #339/#355/#468 procsub suites pass. Oracle: GNU bash 5.2.37 msys (D:\Git\usr\bin\bash.exe) — rc=0 on every accepted shape, byte-identical stdout on executed shapes. Known out-of-scope gap, pre-existing on master: interactive/stdin-source completeness (stdin_source_text_needs_more) and the `-c` space-form body still lack their own arms; truncated-EOF diagnostics unchanged. Tests: tests/issue463_multiline_procsub_word_regressions.rs (9 cases: minimal repro, line-spanning continue, jb-cli nesting, output procsub, comsub-wrapped, single-line forms, #424 rejections, quoted opener). src/executor/path.rs is cargo fmt reformat of pre-existing test code. Closes #463
This was referenced Oct 10, 2026
caomengxuan666
added a commit
that referenced
this pull request
Oct 21, 2026
… and windows_drive.rs The two `bytes[0] as char` drive-letter folds added for niubash#481/#483 each sit behind a `bytes[0].is_ascii_alphabetic()` condition, pinning the widened byte to ASCII — never a UTF-8 continuation byte. Same reviewed-safe class as the existing path.rs/cd/paths.rs/pwd.rs entries. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #463
Problem
word<(NEWLINE ... NEWLINE)— a process substitution attached directly to a word (no space), with its body spanning physical lines — was rejected by rubash withsyntax error near unexpected token ')', while GNU accepts it. This breaks the h4l/json.bashjb-clinesting example:The word scanner itself already consumes the body (
skip_cmd_substspans newlines, rubash#339's<(/>(word arm), but the tokenizer's logical-line join gate had no signal for an open word-attached body: the lineecho outer<(looked complete, and the body lines were parsed as fresh commands.Fix
GNU folds
word<(into the word (read_token fall-through parse.y:3793-3797; shellexp arm parse.y:5494-5524) and reads the(...)body underparse_matched_pair's LEX_GTLT discipline (parse.y:4147-4153), where newlines are ordinary body characters. Mirror that at the join gate:word_ends_in_open_process_substitution(src/lexer/continuation.rs): quote/escape/backtick-aware scan of the last word token's raw span; true iff the word ended inside an unclosed word-attached<(/>(.GroupScanFeeder::push_main_line(src/lexer/mod.rs): when the pass's last token is that word, hold the logical line open for the next physical line (full re-lex — the pass ended mid-word, so the tail-resume checkpoint is invalid).GroupScanFeeder::token_level_needs_more: report the held join so the incremental group reader (script-file and-cexecution) keeps appending physical lines too.Untouched by design: bare
<(at word start (the parser's own procsub bridge already spans lines there), #424's extglob redirect rejections, the #339/#355/#468 procsub behavior.Oracle
GNU bash 5.2.37 msys (
D:\Git\usr\bin\bash.exe):bash -nrc=0 on every accepted shape of the issue's boundary table; executed shapes (echo outer<( NL ... NL), comsub-wrapped) byte-identical stdout (outer/dev/fd/63).Tests
tests/issue463_multiline_procsub_word_regressions.rs— 9 cases: minimal repro (-n+ execution), parsing continues after the closing), the jb-cli nesting shape, output procsub>(, comsub-wrapped, single-line attached forms unchanged, #424 rejections intact, quoted opener does not join, body executes once.Known pre-existing gaps (out of scope, unchanged on master)
stdin_source_text_needs_more) has no arm for either form, so pipedecho outer<(+ lines still errors at).-c/script execution (parse-only via-nis fine).echo outer<(with no body) stay accepted where GNU reportsunexpected EOF while looking for matching)'`.