Repository navigation
fix(executor,lexer): #880 rework -- close the two PR#898 review blockers - #936
Merged
Merged
Conversation
… bail blind spots GNU parse.y:4451 parse_comsub re-parses the $(...) body with the real grammar, so a case clause owns its pattern `)` (parse.y:3465-3468 special_case_tokens); and subst.c:921-931 string_extract_double_quoted folds \" to a bare `"` while scanning the enclosing quotes (stripdq arm). The IFS-marking simulator replayed neither rule, and replayed no backtick line-continuation rule either, so any word pairing a quoted IFS char with one of these shapes desynced the simulated cook, hit the equality-guard bail, and split its quoted IFS: - dquote-wrapped backtick kept `\"` verbatim while the cook folds it (`a="`echo \"x\"`"` gave `"x"` for `x`); the chars-iterator backtick copier gains the dq flag and the dquote walker passes dq=true (outer backticks unchanged). The simulator's dquote backtick arm replays the same fold plus `\<newline>` elision. - backtick `\<newline>` / `\<CRLF>` elision was not replayed in the simulator's dquote backtick arm. - `$(...)` used a naive paren depth count that closed early on `$(case x in ...)` pattern parens; the tail was re-walked as outer text, so a `\`/`"`/`'` there desynced the cook and split quoted IFS (e.g. `"a b"$(case x in x) echo \$y;; esac)` gave `a` + `b$y`). Now case-aware, arm-for-arm with copy_dollar_paren_body_raw via the shared update_command_substitution_case_depth machine (parse.y:3710/ 3759, 3181/3183, 3630-3643; rubash#276/#284/#380/#513), with opaque quote/comment/nested-$() span skips (widened to pub(crate) with a lexer-level re-export). Mismatch still bails (safe direction); fixed shapes no longer bail. Evidence: target/probe/880r.sh + 880s.sh + 880t.sh + 880u.sh byte-match WSL GNU Bash 5.3.15; new tests/issue880_comsub_case_ifs_mark_regressions.rs 6/6; #868 7/7 + #876 7/7; regression 78/78; lib 706 + 1 pre-existing env-flaky windows_listing_cache (fails on clean master too).
Addresses the REQUEST-CHANGES findings on PR#898 (which builds on the same #880 mark_quoted_ifs_from_raw simulator approach): - The in_double backtick arm of the simulator pushed DATA_DQUOTE where the cooked word holds a bare '"' — copy_backtick_body_cursor(dq=true) folds \" to 0x22 (GNU subst.c:921-931 string_extract_double_quoted stripdq arm), so simulated != cooked bailed on every command-word shape with an unquoted expansion sibling. Push '"' instead. - copy_comsub_body_verbatim_for_ifs_marking's backtick-body '_' arm single-stepped after pushing '\', letting an escaped ` close the backtick early so a leftover ) closed the $() and the tail re-walked as outer text. Consume backslash+escaped as a pair, arm-for-arm with copy_backtick_body_preserving_syntax(_dq). - Merge the two outer backtick arms into one dq=in_double arm so the unquoted arm also elides \<newline>/\<CRLF>, matching copy_backtick_body_cursor's dq-independent elision. - Face 2 family (review point 4): $"..." on the command-word walk routed through remove_double_quoted_into_cursor(preserve_backticks= false) and shipped the backtick body's \" as DATA_DQUOTE data. Flip to true — $" cooks by the same double-quote rules as " (the locale prefix is translation markup only; subst.c:925-932 backquote mode applies identically), matching the assignment walk's $" arm. Regression tests add the command-word reproducer forms from the review (dquote backtick + unquoted sibling; nested escaped backtick inside $(); $" and $(...) sibling variants). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This was referenced Oct 21, 2026
Closed
caomengxuan666
added a commit
that referenced
this pull request
Oct 21, 2026
…span (#977) fix(executor): ${...} IFS-mark copy arm uses the cook's own dolbrace span (#977) mark_quoted_ifs_from_raw's ${...} verbatim copy arm scanned the body with a naive {/} depth count plus a backslash skip: a } inside '...'/"..."/ `...`/$(...)/nested ${...} was counted as the close, the span ended early, the tail re-walked as outer text, the simulated cook diverged from the real one and the equality guard bailed the whole mark pass -- quoted IFS chars lost \x1c protection and field-split ("a b"${x:-'}'}$w printed <a> <bVp> <q>). GNU anchors: parse.y:3877 parse_matched_pair (P_FIRSTCLOSE|P_DOLBRACE, called for ${...} from read_token_word at parse.y:5513) skips quoted regions, command substitutions and nested braces opaquely, and counts a nesting level only for ${ -- a bare { never nests. The arm now delegates the span end to the same functions the cook's own ${ path runs -- lexer/quotes.rs copy_braced_parameter_unquoted_cursor (outer) / copy_braced_parameter_after_dollar_cursor (inside "...", dolbrace.rs scan_braced_parameter underneath) -- so the simulated boundary is the cooked boundary by construction (same per-arm replication pattern as the #936 $(...) arm). posix_mode_enabled() is plumbed through for the inside-double-quote Interp 221 context, matching copy_braced_parameter_after_dollar's context argument. Fixes #977 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.
Summary
Implements the REQUEST-CHANGES review findings on #898 (comment 6290178882), built directly on top of the original author @a-rookie-of-C-language's branch head
80aea329.maintainerCanModifyis false on #898, so this lands as a follow-up PR — original authorship is preserved (the base commit is theirs); whichever of the two PRs merges first wins.in_doublebacktick arm pushedDATA_DQUOTE(\x18) for\", but the cooked word holds a bare"(0x22) —copy_backtick_body_cursor(dq=true)folds the escape (GNUsubst.c:921-931string_extract_double_quotedstripdq arm).simulated != cookedguaranteed a bail on any command word carrying an unquoted expansion sibling. Now pushes'"'.printf '<%s>\n' "a b\echo "x"`"$w→\`` inside a$()-nested backtick closed the span early.**copy_comsub_body_verbatim_for_ifs_marking's backtick-body_arm single-stepped after pushing`, so the escaped backtick was re-read as a closer and the leftover)then closed the$(); the tail re-walked as outer text and desynced the cook. Now consumes\+escaped as a pair, arm-for-arm withcopy_backtick_body_preserving_syntax(_dq)/copy_backtick_body_cursor.printf '<%s>\n' "a b"$(echo \echo \`echo \\)`\\\$y)→<a b)><$y>(matches WSL GNU 5.3.0).dq = in_doublearm, so the unquoted arm also elides\<newline>/\<CRLF>exactly likecopy_backtick_body_cursordoes under either flag (previously latent becauseGroupScanFeeder::push_main_linestrips main-line continuations).$"..."cooked throughpreserve_backticks=false. The command-word walk shipped the backtick body's\"asDATA_DQUOTEdata, so$"a b\echo "x"`"$wprinteda b"x"p. Flipped totrue:$"cooks by the same double-quote rules as"(the locale prefix is translation markup only;subst.c:925-932backquote mode applies identically) — this also matches the assignment walk's$"arm, which already passestrue. Note this was *required* alongside Blocker 1: with the simulator now emitting the correct bare", the wrong cooked side would have regressed the shape from "wrong chars" to "wrong chars + split". Both point-4 forms now match GNU (Test plan
cargo test --test issue880_comsub_case_ifs_mark_regressions— 10/10 (4 new command-word reproducer tests from the review)cargo test --test issue868_carrier_ifs_mark_regressions— 7/7cargo test --test issue876_multibyte_quoted_ifs_mark_regressions— 7/7cargo test --lib— 707/707;--test lexer_quote_tests16/16;quote_in_double_quote4/4;marker_leak_golden8/8;assignment_quote_roundtrip9/9;array_compound_quote13/13--test regression77/78 — sole failureupstream_suite_slice_snapshots("no suite files under third_party/bash/tests", worktree lacks the vendored subtree; same environment-bound failure the reviewer noted in the master baseline)<a bxp>/<q>, p08<a b)>/<$y>, p4a$"form<a bxp>/<q>, p4b$(...)sibling<a bxp>/<q>— all byte-equal to the GNU 5.3.0 columns quoted in the reviewRefs #898, #880
Generated with Devin