Skip to content

[bug] assignment y="($x)" leaks 0x10 + quotes into the stored value #3034

Closed

Description

@caomengxuan666

Summary

An assignment whose right-hand side contains ( + an expansion + ) leaks a 0x10 carrier byte plus a pair of " into the stored value. The same expansion in command-argument position decodes correctly — only the assignment path leaks.

Repro

x=v1.0; y="($x)"; printf '%s' "$y" | od -An -tx1

GNU bash 5.3.20: 28 76 31 2e 30 29 ((v1.0)).
rubash master 6eb861b8: 28 10 22 76 31 2e 30 22 29 ((\x10"v1.0")).

Controls

  • Argument position is clean: printf '%s' "($x)" → (v1.0) on both shells.
  • y="$x", y="[$x]", y="x$x" are clean on both shells.
  • Also leaks: y="(${x})", y='('$x')' (single-quoted parens + unquoted expansion).

Root of #3005 (recorded here, with a correction)

This is the root of #3005's __git_ps1 detached-HEAD symptom: git-prompt.sh's detached branch does b="$(git describe …)" and then b="($b)" — the second step is exactly this shape. #3005's body claims the root is in command-substitution-capture decoding; that claim is disproven by captain probe on master:

When this fix lands and is verified (regression pin + __git_ps1 detached chain re-run), #3005 should close with it. #3005 stays open until then.

Fix surface (suspected)

src/executor/assignment_expansion.rs — assignment-path marker decode gap (same file #3016 is repairing; this issue queues behind #3016). Regression pin: y="($x)" byte assertion + __git_ps1 detached ((v1.0)).

Source

eco-2907 REPORT F1 (git contrib chain, master 6eb861b8, GNU 5.3.20 oracle; captain reproduced F1 + all controls + the #3005 disproof probes on master).

Activity

  1. added
    bug
    gnu-baseline
    on Nov 7, 2026
  2. added
    area:expansion
    on Nov 7, 2026
  3. caomengxuan666 commented on Nov 8, 2026

    @caomengxuan666
    MemberAuthor

    Closed by merged PR #3056 (squash merge 873b30e6, 2026-11-08).

    Captain verification (head fd6e13e5, true base 30ddc122; full record in the captain review):

    • Regression pins on head: 12 passed / 0 failed; transplanted onto the base: 2 passed / 10 failed (fail-first holds).
    • Neighbours: 45/0 across 7 stems (issue3016 8/0, array_compound_quote 17/0, assignment_quote_roundtrip 9/0, assignment_chain 4/0, assign_prefix_subshell 4/0, issue1113 1/0, array_store_parity 2/0).
    • Full lib: head 1197/0/4, base 1197/0/4 — identical.
    • GNU probes byte-identical, including the __git_ps1 分离头描述值泄漏载体字节 U+0010 与引号(t9903 六例) #3005 __git_ps1 chain shape.
    • RUSTFLAGS="-D warnings" rc=0; hygiene clean; fmt clean; CR zero. CI on the merged head: 10 green + 1 skipping, CLEAN.

    Root cause: the compound-expansion functions were called on any paren-shaped value without the parser's compound判定, so y="($x)" was claimed as an element list and its transport product stored raw. The fix gates all three call sites on COMPOUND_ASSIGNMENT_MARKER.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:expansionbuggnu-baseline

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions