Skip to content

fix(executor): keep quoting state on quoted compound elements (#377) - #730

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/issue377-declare-quoted-glob
Oct 17, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/issue377-declare-quoted-glob

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

fix(executor): keep quoting state on quoted compound elements (#377)

What

x='*'; declare -a d3=("$x") stored the glob matches instead of
literal * (same for ("*") literals). Even a quoted literal globs;
unquoted (*) correctly globs. Quoting was dropped, not honored.

Root cause

The NoMatch arm of the compound-element expander pushed
marker+dequoted text for whole-quoted tokens; the storage consumer
then globbed the DEQUOTED text. GNU globs the STILL-QUOTED word
(glob_expand_word_list, subst.c:12604, runs on CTLESC-laden text;
dequote comes after) — quoted content never matches. (An earlier
wrong theory blaming double-CTLESC-marking was disproven by unit
test; the token stream probes pinned the real chain.)

Fix

  • Producer: whole-quote-wrapped NoMatch tokens serialize CTLESC
    protection INSIDE the quotes (like the existing CTLESC serializer);
    unwrapped tokens keep the old form (their quotes, if any, are DATA).
  • Consumer = arm: dequote-CTLESC the subscript left side before
    array_assignment_index (no-op when absent), so protected [2]
    still binds.

Verification

  • Repros byte-identical to GNU (quoted literal, quoted $x,
    unquoted glob, [2]=v/a=b/a b edges).
  • issue377 file 10/12 → 11/12 (rest is the pre-existing,
    base-identical dot-IFS empty-member divergence).
  • glob_diff.sh 34/34, casearm_diff.sh 30/30, lib 596/596,
    declare executor subset 61/61.
  • Full serial failure-set gate vs master: per-target results match
    except the fixed file itself (11/1 vs 10/2). Zero NEW tests; the
    single DISAPPEARED is the fixed test. (The tool's cli_tests/
    issue297_300 NEW-target rows are the known parse artifact.)
    No regression.
  • niubash product A/B (niubash pinned 6295367, only rubash [patch]
    switched): failure sets byte-identical (8=8).

Whole-quote-wrapped NoMatch elements were pushed marker + dequoted
text; the consumer globbed the dequoted text, dropping quoting state
(declare -a d3=("$x") with x='*' stored the matches). Serialize
CTLESC protection inside the quotes instead; dequote the subscript
left side for index parsing (no-op when absent).

issue377 file 10/12 -> 11/12 (rest is pre-existing empty-member);
glob 34/34, casearm 30/30, lib 596/596.
@caomengxuan666
caomengxuan666 merged commit 365472c into master Oct 17, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/issue377-declare-quoted-glob branch October 17, 2026 03:57
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.

1 participant