Problem
set -a (allexport) is parsed and the flag SHOPT_a is stored, but the behavior is not implemented:
option_name_to_var() in builtins/vars.rs:37-48 does not map "allexport", so set -o allexport is silently ignored
- Nothing checks
SHOPT_a during variable assignment — new/modified variables are never auto-exported
This is used by frameworks like wedow/harness to load session environment files:
set -a
source "${HARNESS_SESSION}/.env"
set +a
Expected behavior
When set -a is active, every variable assignment (via =, read, for loop variable, etc.) should also mark the variable as exported. set +a disables this. set -o allexport and set +o allexport should work as aliases.
Test cases
Basic allexport
set -a
FOO="bar"
BAZ="qux"
set +a
AFTER="not-exported"
# Check export status
env_output="$(env)"
echo "${env_output}" | grep -c "^FOO=bar$"
echo "${env_output}" | grep -c "^BAZ=qux$"
echo "${env_output}" | grep -c "^AFTER="
# Expected stdout:
# 1
# 1
# 0
allexport with source
cat > /tmp/vars.env <<'EOF'
DB_HOST=localhost
DB_PORT=5432
EOF
set -a
source /tmp/vars.env
set +a
cat > /tmp/check-env.sh <<'SCRIPT'
#!/usr/bin/env bash
echo "host=${DB_HOST:-unset}"
echo "port=${DB_PORT:-unset}"
SCRIPT
chmod +x /tmp/check-env.sh
/tmp/check-env.sh
# Expected stdout:
# host=localhost
# port=5432
set -o allexport / set +o allexport
set -o allexport
X="hello"
set +o allexport
Y="world"
export -p | grep -c "declare -x X="
export -p | grep -c "declare -x Y="
# Expected stdout:
# 1
# 0
Short flag in combined options
set -eau
MY_VAR="test"
set +a
export -p | grep -c "declare -x MY_VAR="
# Expected stdout: 1
allexport applies to read builtin
set -a
echo "value" | read -r MY_READ_VAR
set +a
# MY_READ_VAR should be exported
export -p | grep "MY_READ_VAR" | head -1
# Expected stdout: declare -x MY_READ_VAR="value"
allexport applies to for loop variable
set -a
for item in alpha beta; do
: # item should be exported on each iteration
done
set +a
export -p | grep -c "declare -x item="
# Expected stdout: 1
Variables assigned before set -a are not retroactively exported
BEFORE="exists"
set -a
DURING="new"
set +a
export -p | grep -c "declare -x BEFORE="
export -p | grep -c "declare -x DURING="
# Expected stdout:
# 0
# 1
Implementation hint
- Add
"allexport" => Some("SHOPT_a") to option_name_to_var() in builtins/vars.rs
- Add
"allexport" entry to SET_O_OPTIONS array for display
- In variable assignment paths, check if
SHOPT_a is "1" and if so, also insert into self.env (the export set)
- Key locations:
process_command_assignments, execute_local_builtin, for loop variable assignment, read builtin side effects
Problem
set -a(allexport) is parsed and the flagSHOPT_ais stored, but the behavior is not implemented:option_name_to_var()inbuiltins/vars.rs:37-48does not map"allexport", soset -o allexportis silently ignoredSHOPT_aduring variable assignment — new/modified variables are never auto-exportedThis is used by frameworks like wedow/harness to load session environment files:
Expected behavior
When
set -ais active, every variable assignment (via=,read,forloop variable, etc.) should also mark the variable as exported.set +adisables this.set -o allexportandset +o allexportshould work as aliases.Test cases
Basic allexport
allexport with source
set -o allexport / set +o allexport
Short flag in combined options
allexport applies to read builtin
allexport applies to for loop variable
Variables assigned before set -a are not retroactively exported
Implementation hint
"allexport" => Some("SHOPT_a")tooption_name_to_var()inbuiltins/vars.rs"allexport"entry toSET_O_OPTIONSarray for displaySHOPT_ais"1"and if so, also insert intoself.env(the export set)process_command_assignments,execute_local_builtin,forloop variable assignment,readbuiltin side effects