Skip to content

[bug] set -a wrongly marks arrays -x #2945

Closed

Description

@caomengxuan666

Summary

With set -a (allexport), GNU does NOT mark arrays for export (arrays cannot be exported): declare -p shows plain declare -a. rubash wrongly adds the -x attribute to arrays created by compound assignment under set -a.

Repro

set -a; arr=(1 2); declare -p arr
GNU bash 5.3.20 rubash master 500769e
output declare -a arr=([0]="1" [1]="2") declare -ax arr=([0]="1" [1]="2")

Scope (morph, GNU vs rubash, two passes, identical)

  • DIFF: indexed compound arr=(1 2) (mC1), associative declare -A m=([k]=v) (mC2, GNU declare -A, rubash declare -Ax), empty arr=() (mC3), declare -a arr=(1 2) (mC5).
  • SAME (controls): subscript assignment arr[0]=x under set -a shows no -x on either shell (mC4); printenv arr fails (rc 1) on both — the spurious -x is attribute-only and does not actually export (mC7); scalar s=x under set -a is correctly -x on both (mC8); no set -a shows no -x on either (mC6). So the defect is the compound-assignment array-creation path adding -x under allexport, while the subscript-assignment path is correct.

Regression seed:

set -a; arr=(1 2); case "$(declare -p arr)" in *"ax "*) echo "array-no-x: FAIL";; *) echo "array-no-x: PASS";; esac

Expected (GNU): array-no-x: PASS. Actual (rubash master 500769e): array-no-x: FAIL.

Source

Differential hunt r79 (set/shopt option semantics, second round), oracle GNU bash 5.3.20, verified on fresh master build 500769e (two passes, stable).

Activity

  1. added
    bug
    gnu-baseline
    area:builtins
    on Nov 7, 2026
  2. added a commit that references this issue on Nov 12, 2026
    9fbeedd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:builtinsbuggnu-baseline

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions