Repository navigation
WIP: fix(lexer): #2227 face 2 — dquote-span bracket hunt EOF attribution (face 1 withheld) - #2373
Merged
Merged
Conversation
…elf (Refs #2227) Face 2 of #2227: an unterminated dollar-bracket inside a double-quoted span named the DQUOTE at the span's line, because db_scan_dquote_span bounded the hunt by the span's closing quote and counted brackets inside it. GNU runs the hunt itself: extract_delimited_string (subst.c:1361) — reached for the bracket form at subst.c:1303 with flags=0 — recurses into quote units (subst.c:1448-1457, via skip_single_quoted subst.c:1127 / skip_double_quoted subst.c:1014), so the span's closing quote OPENS a quote unit inside the hunt and that unit's EOF names the quote at the unit's line. db_scan_dquote_span now delegates an in-span hunt to db_scan_bracket_hunt verbatim; the bounded-count path and db_tail_has_unclosed_quote are gone (the q6 verdict — trailing quote closes the opened unit, hunt names the bracket — now comes straight from the hunt). script_driver.rs and the issue543 pin docs updated to the new attribution. Verified: issue543 pins 14/14, issue2227 face-2 pins 4/4 (GNU bash 5.3.20 script-file probes).
Four pins for the delegated-hunt verdicts (quote unit names itself at its own line; no closing quote names the bracket; squote unit inside the hunt names itself; trailing quote closes the unit then bracket EOF) plus two control pins holding GNU-agreeing shapes (backquote/escape family, nested/subscript family). Face-1 extraction pins are deliberately absent — see the file header and the PR body for the withheld face-1 state and its regression.
caomengxuan666
marked this pull request as ready for review
October 31, 2026 16:02
caomengxuan666
added a commit
that referenced
this pull request
Nov 1, 2026
…r the s2 line (rubash#2227) issue2227_nested_and_subscript_controls expected `s2: 21` for echo "s2: $[a["1"]+1]", but GNU 5.3.20 rejects that line itself: inside double quotes the bare " after a[ closes the segment (subst.c:1014 skip_double_quoted has no $[...] case), extraction over the segment `s2: $[a[` finds no ] and the command is discarded with `bad substitution: no closing ']' in s2: $[a[` (subst.c:1505) while the script continues — stdout s1: 21 / n: 3 / bt: 6, rc 0. The expectation predates the #2441 segment semantics (written for #2373). The pin now asserts the GNU outcome; no product change. Verified byte-for-byte against GNU 5.3.20 with the pin's own script. Refs #2227.
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.
Refs #2227 — recovery delivery: face 2 only. Face 1 is withheld, with evidence (below).
What lands (face 2: EOF verdict attribution)
An unterminated
$[...]hunt inside a double-quoted span used to be bounded by the span's closing quote and named the DQUOTE at the span's line. GNU runs the hunt itself —extract_delimited_string(subst.c:1361, reached for$[...]at subst.c:1303 with flags=0) recurses into quote units (subst.c:1448-1457 viaskip_single_quotedsubst.c:1127 /skip_double_quotedsubst.c:1014) — so the span's closing quote opens a quote unit inside the hunt, and that unit's EOF names the quote at the unit's line.src/lexer/skip.rs:db_scan_dquote_spandelegates an in-span hunt todb_scan_bracket_huntverbatim; the bounded-count path anddb_tail_has_unclosed_quoteare removed (the q6 verdict — trailing quote closes the opened unit, then the hunt names]— now comes straight from the hunt). Forecho "a $[1+<NL>2"the verdict is now"at line 2 (GNU 5.3.20), not line 1.src/script_driver.rs,tests/issue543_dollar_bracket_eof_regressions.rs: verdict-attribution comments updated.tests/issue2227_bracket_quote_regressions.rs(new): 4 face-2 pins + 2 control pins.Verification (this branch, scrubbed-fd runner): issue2227 pins 6/6, issue543 pins 14/14,
cargo check --testsclean, kept files 0 CR, no new warnings in kept files.Withheld: face 1 (quote-state-aware extraction) — recovered but NOT sound yet
The recovered worktree also contained a full face-1 implementation (lexer copiers in
quotes.rs, walker collectors inembedded_mutations.rs/embedded_parameters.rs,dollar_bracket_endinexpand_braced_replacement.rs, all converted to theextract_delimited_stringstate machine). Adjudication against GNU 5.3.20 + master A/B (base 711ad72) found:echo "dblbs: $[1\\]+2"prints literally. Master and GNU both produce the arithmetic error (token\). Root cause: the cooked body ends in a lone\(from\\), and the walker collector's new escape arm consumes the closing]as that backslash's escaped char, so the span never closes. At the cooked-word layer a source\]and a deescaped\are indistinguishable to the collector as written — this is carrier-layer (CTLESC) territory and needs its own brief, not a drive-by patch.\]where GNU shows](the evaluator's error token is not dequoted), and assignment-position quoted bodies (v=$["1+1"]) still error (also red on master, different shape).Full-diff pin run for the record: 7 passed / 4 failed. The face-1 diff is preserved in the cluster workdir (
face1-layers.diff, 611 lines) for the follow-up brief; the five face-1 pin drafts were removed from the pin file rather than shipped red or weakened.#2227 stays open for face 1.