Skip to content

[bug] declare -n on an existing array renders the VALUE array-serialized in the 'invalid variable name for name reference' error (GNU prints the raw string) #356

Closed

Description

@caomengxuan666

Found by gnusweep3 lane (orphan sub nameref22.sub — never referenced by any GNU suite; WSL GNU Bash 5.3.0 oracle, worktree 0fe8d0f). Serialization-rendering cousin of the #214 family.

Repro:

declare -a array=(zero)
declare -n array='(one two three)'

GNU 5.3.0 stderr: line 2: declare: (one two three)': invalid variable name for name reference— the raw RHS string. rubash stderr:line 2: declare: ("one" "two" "three")': invalid variable name for name reference — the value has been round-tripped through array serialization (quotes and double spaces injected).

GNU C owner: builtins/declare.def:576 — builtin_error (_("%s': invalid variable name for name reference"), value)` prints the raw value string; no re-serialization happens.
Artifacts: target/issue-suites/results/gnusweep3/orphan/case/nameref22.; minimal target/issue-suites/results/gnusweep3/probes/min/m25-nameref-value-render.

Activity

  1. added
    bug
    gnu-baseline
    on Sep 30, 2026
  2. added 2 commits that reference this issue on Sep 30, 2026
  3. caomengxuan666 commented on Sep 30, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt20/deepsweep (437cd6eb): declare -n invalid-value error prints the raw text, not the array serialization (declare.def:576).

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

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions