Repository navigation
fix(executor): function-name prolog for readonly -a/-A nested declare replays (Refs #2658) - #3698
Merged
Merged
Conversation
… replays (Refs #2658) setattr.def:231-251 turns `readonly -a r=(6)` / `export -A m=(x)` into a nested `declare -gra`/`declare -grA` replay, so the readonly refusal is declare's own sh_readonly (declare.def:876) reported through builtin_error — whose this_command_name at expansion time is the enclosing function name (builtins/common.c:83-105; the builtin name is installed only after expand_words, execute_cmd.c:4800). Flagless `readonly r=(4)` reduces to a scope-only `declare -g r` that succeeds, so its refusal arrives later from the bind layer's err_readonly (error.c:453) and stays bare. The compound-operand path now picks the function-prefixed prolog when the builtin is declare/typeset/local OR when -a/-A hints mark an attribute replay; flagless readonly/export keep the bare diagnostic. DISCARD (subst.c:13033) still applies to the special builtins.
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Residual cells of
issue2658_readonly_compound_function_abort(3 red):GNU reports
f: r: readonly variable(enclosing function name) when areadonly -a/readonly -A/export -a/export -Acompound operand failsthe readonly check inside a function; rubash printed the bare
r:form.Root cause:
setattr.def:231-251replaysreadonly -a r=(6)as nesteddeclare -gra r(subst.c:12949expand_declaration_argument→subst.c:12792
make_internal_declare), so the refusal is declare's ownsh_readonly(declare.def:876) viabuiltin_error(builtins/common.c:83-105) —
this_command_nameis the enclosingfunction name because the builtin name is installed only after
expand_words(execute_cmd.c:4800). Flaglessreadonly r=(4)reduces toscope-only
declare -g rwhich succeeds, so its refusal is the bindlayer's
err_readonly(error.c:453report_error) — bare name.The prolog class now covers declare/typeset/local always and
readonly/export only under -a/-A replay. DISCARD (subst.c:13033
exp_jump_to_top_level) still applies to the special builtins.Legs
issue2658_readonly_compound_function_abort6/6 green (was 3/6),issue2658_readonly_compound_abort12/12 green — WSL,cargo test(declare/readonly/local/export × -a/-A × in/out of function)
issue0077_declare_regressions (1), issue1471_local_global (1)
cargo build --locked,cargo fmt --check,RUSTFLAGS=-D warnings cargo checkall cleanTest plan