Skip to content

fix(executor): keep quoted whole-word default expansions one compound element - #466

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/compound-array-quoted-default
Oct 9, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/compound-array-quoted-default

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes #432

Problem

a=("${v:=x y}") stored two elements (x, y) where GNU stores ONE element x y (same for ${v:-x y}; plain ("$v") was fine). wt66-adjacent compound-array quoted-expansion family.

Root cause

whole_word_parameter_single_value (the whole-word ${...} fast path for compound array elements) only claimed plain names and array references. A whole-word ${name:=word} / ${name:-word} / ${name=word} / ${name-word} / ${name:?word} token therefore fell through to the embedded-parameter walker, whose re-quoted splitter treats expansion output whitespace as live IFS data — the default word's space split the quoted element into two.

Fix

Claim the word-producing operator family in whole_word_parameter_single_value with ONE expand_word pass (the same ${} re-expansion the embedded walker performs, so the := side effect still runs exactly once). Through this helper the compound splitter sees the token as a whole-word parameter and a wholly double-quoted token keeps GNU's W_QUOTED no-split semantics (subst.c:12050): one element x y.

  • Unquoted tokens keep GNU's field split: a=(${v:=x y}) stores 2 elements and still assigns v=x y.
  • +/:+ alternates keep their dedicated fanout path (rubash#315); at-list ([@]/[*]), indirect (!) and length (#) bodies stay out of the new arm.
  • declare -a a=("${v:=x y}") and the [sub]="${v:=x y}" element form pick up the same gluing (W_NOSPLIT).

Tests

New suite tests/issue432_compound_quoted_default_regressions.rs (13 tests): the issue repro, no-space default, :-/=/:? family (set + unset + error paths), unquoted field-split, set-variable non-use, declare/subscript/scalar non-compound guards, IFS insensitivity, and the rubash#315 + guard idioms.

Related suites (array_compound_quote_regressions, issue148, issue298_299, issue369, issue391, --lib) green. Full cargo test --tests --no-fail-fast failure set compared byte-for-byte against the unmodified branch tip: identical (all pre-existing environment failures on this Windows box, incl. the pre-existing guard_147_idioms_stay_green failure that also fails on baseline); no regressions.

@caomengxuan666
caomengxuan666 merged commit d34a1d7 into master Oct 9, 2026
7 of 8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/compound-array-quoted-default branch October 9, 2026 14:03
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.

[P2] compound-array quoted default ${v:=x y} inside ("${v:=x y}") stores wrong elements (wt66-adjacent family)

1 participant