Repository navigation
Fix compound-assignment field split of decoded $'…' blanks in mixed-quote elements (Refs #4200) - #4286
Merged
Conversation
…lements
In a plain compound assignment, an element concatenating a $'...'
segment with another quoted segment had its decoded blank bytes
(tab, newline) replaced by spaces: f=('a'$'x\ty') stored 'ax y'
instead of 'ax<TAB>y'. The compound walker decodes $'...' and
re-wraps it in raw quotes with the U+E401 ANSI_C_IFS_GUARD marker
intact, but split_requoted_hoisted_compound_word had no arm for the
guard, so the guarded byte fell to the bare-IFS arm, was field-split
and re-joined with a space. GNU hands the decoded span back wrapped
by sh_single_quote (parse.y:5564-5571) and never splits it. A new
guard arm glues the guard and the following byte into the current
field (+16 lines, single mechanism). The issue's title forms were
already correct on master; 14 new pins cover them plus every
corrupting and control shape. Bucket 52/52.
Refs #4200 (not Fixes).
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 #4200. UNVERIFIED-BY-CAPTAIN.
Boundary mapping of #4200 on current master (
60ed70e5), all forms compared byte-for-byte (stdout/stderr/rc) against GNU bash 5.3.20 with script-file probes:f=('a'"b"'c)and every other mixed-quote element form from the issue are already correct on master (fixed by fix(expand): single-quote backslash is data — one pass_next quote-state rule (rubash#4195) #4201 or an earlier quote-span commit) — pinned by the new tests so they cannot regress silently.$'…'segment with another quoted segment had its ANSI-C-decoded blank bytes (\t,\n) replaced by spaces —f=('a'$'x\ty')storedax yinstead ofax<TAB>y.Root cause: the compound walker correctly decodes
$'…'and re-wraps it in raw'…'text with the U+E401ANSI_C_IFS_GUARDmarker intact, butsplit_requoted_hoisted_compound_wordhad no arm for the guard and does not track raw'…'as a span, so the guarded byte fell to the bare-IFS arm and the element was field-split (then re-joined with a space). GNU never splits here: parse.y:5564-5571 hands the decoded span back wrapped bysh_single_quote.Fix (single mechanism, +16 lines in
src/executor/assignment_expansion.rs): a newANSI_C_IFS_GUARDarm insplit_requoted_hoisted_compound_wordglues the guard and the following byte into the current field; the storage unquote already strips the guard.Tests: 14 new pins in
tests/issues_4200_4299/issue4200_compound_mixed_quote_elements.rs(title forms, EOF-unclosed diagnostic, all corrupting shapes, and the control shapes: whole-element$'…', declare/subscript forms, TAB-valued IFS, quoted parameter tab, and the GNU field-split of unquoted command substitution). Bucket: 52/52 pass;array_compound_quote_regressions: 18/18.Not in this PR (characterized in the lane dossier for a separate ticket): when a malformed compound assignment's quote spans into the next line, GNU reports the error at the offending token's line, discards the command, and continues; rubash reports at the assignment's first line and aborts. Same-line forms already match GNU on both sides.