Skip to content

[bug] set -a (allexport) ignored by local/readonly initialization #2944

Closed

Description

@caomengxuan666

Summary

With set -a (allexport), GNU marks every subsequently created variable for export — including variables created with an initializer by the local and readonly builtins. rubash does not: local z=9 / readonly r=1 under set -a leave the variable unexported.

Repro

set -a; f(){ local z=9; printenv z; }; f
set -a; readonly r=1; printenv r
GNU bash 5.3.20 rubash master 500769e
local facet prints 9 prints nothing (rc 1)
readonly facet prints 1 prints nothing (rc 1)

declare -p confirms the missing attribute:

set -a; f(){ local z=9; declare -p z; }; f
# GNU:    declare -x z="9"
# rubash: declare -- z="9"

set -a; readonly r=1; declare -p r
# GNU:    declare -rx r="1"
# rubash: declare -r r="1"

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

Regression seed:

set -a; f(){ local z=9; [ "$(printenv z)" = "9" ] && echo "local-export: PASS" || echo "local-export: FAIL"; }; f
set -a; readonly r=1; [ "$(printenv r)" = "1" ] && echo "readonly-export: PASS" || echo "readonly-export: FAIL"

Expected (GNU): both lines PASS. Actual (rubash master 500769e): both lines 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