Skip to content

Single-quoted ${@} in a compound array assignment expands instead of staying literal: A=('${@}') stores the parameter values (GNU stores one literal element) #303

Closed

Description

@caomengxuan666

Found by wt10/fieldsplit while fixing #298 (adjacent pre-existing defect, verified identical before/after that fix): A=('${@}') — with single quotes the element must stay the LITERAL four characters ${@} (GNU stores one such element), but we expand it. Unquoted and double-quoted forms are correct. Quote-promotion (E307 carrier) interacting with the compound walker; same function family as #298's assignment_expansion.rs paths. GNU anchor: arrayfunc.c:585 parse_string_to_word_list keeps W_QUOTED, and single-quoted spans carry no expansion.

Activity

  1. added
    bug
    on Sep 28, 2026
  2. added a commit that references this issue on Sep 28, 2026
  3. caomengxuan666 commented on Sep 28, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt11/almix (f9d9be44, master): fieldsplit's '$@' guard checked the ORIGINAL quote delimiters, but expand_assignment_value_hoisting had already hoisted them to E307 sentinels — the guard could never hit; deeper, hoist_data_single_quotes' ${...}/$'...' skip branches applied INSIDE the span too, letting the live ${@} through to the walker. Both skip branches now carry a !in_span gate (fixing the wrong invariant, not adding a guard); in-span $ takes the existing SQ_DOLLAR_DATA channel. GNU anchors: arrayfunc.c:557-610 -> parse_string_to_word_list (W_QUOTED word) -> expand_words_no_vars never sees live ${...} inside a quoted span.

    Verification: full class byte-identical to WSL GNU Bash 5.3.0 — '${@}' (one literal element), 'a${@}b', 'a${v}b', '${v:-y}', '${*}', '${#}', 'a$1b', 'a\b'; #298 neighborhood guarded ("${@}" fan-out and bare $@ splitting unaffected); 503/27/12/10 gates green.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions