Repository navigation
r79: allexport local/readonly + array marks, assoc subscript single-eval, source diagnostic name - #2962
Merged
Conversation
One integration stem per issue, expectations cross-checked against GNU bash 5.3.20 oracle probes on master 4f74741. Fail-first tallies on master: issue2944 4p/6f, issue2945 4p/6f, issue2946 3p/5f, issue2947 4p/2f — every in-scope facet fails, every control (including the flagless-declare -ax quirk) passes.
…tic name Refs #2944: execute_local gains the valued-operand allexport post-pass declare already had (bind_variable_value, variables.c:3366-3367); apply_readonly_arg marks on its bind shapes (bind_variable tail, variables.c:3211-3212; creation bind in set_var_attribute). Valueless locals, -a/-A creations, subscript and compound operands do not mark, matching the GNU bind each performs. Refs #2945: the plain-assignment tail no longer marks compound binds (do_compound_assignment, subst.c:3441, never reaches a marking primitive), and the declare post-pass stands down when the invocation's -a/-A attribute ends set (make_new_array_variable variables.c:2798 / make_new_assoc_variable variables.c:2851). The flagless declare -ax quirk is preserved and pinned. Refs #2946: expand_command_word now attempts prepare_array_element_assignment_word before the whole-word pass for every associative element assignment (GNU has no whole-word pass for assignment words, general.c:480; the subscript expands once, arrayfunc.c:392-398). The side-effect-free predicate whose only call site was the old gate is deleted. Refs #2947: the source builtin's file-not-found diagnostic names the invoked builtin (source.def:179 via this_command_name, builtins/common.c:93-94) instead of a hardcoded dot. Two pins added with the code: local +a initializer (2944) and declare +a scalar control (2945) — the -a/-A stand-down keys on the attribute's final state.
caomengxuan666
marked this pull request as ready for review
November 7, 2026 04:56
caomengxuan666
added a commit
that referenced
this pull request
Nov 7, 2026
… function (Refs #2963 #2964) (#2977) Two allexport marking residuals from the r79 batch: - #2963: a scalar bind over an existing indexed array went through `set_process_env` (a no-op for ordinary names), so the EXPORTED attribute was never set. GNU's array arm of bind_variable_internal stores element 0 and its tail (variables.c:3211-3212) still applies mark_modified_vars. The arm now calls mark_exported, exactly like its assoc twin in the same function. - #2964: inside a function (without -g), `declare` runs in GNU's local context, where a compound operand is created through the local array machinery and do_compound_assignment (subst.c:3441, ASS_MKLOCAL) — neither marks. The #538 allexport post-pass now stands down for compound operands in the local context (compound judged as in declare.def:935-947); scalar operands there still mark via bind_variable_value. The top-level -ax quirk and declare -g behaviour are unchanged and pinned as controls. Captain verification: new pins 8/8 and 10/10 re-run (fail-first 5/3 and 6/4), the #2962 control stems 11/11, 11/11, 8/8, 6/6, full lib 1188 passed / 0 failed / 4 ignored, RUSTFLAGS="-D warnings" clean, hygiene and per-file rustfmt clean, and a 9-cell probe against GNU bash 5.3.20 identical on every in-scope cell. The one remaining probe divergence (declare arr[0]=x over-marked -x in both contexts) is pre-existing on master and is filed as #2980. 本 PR 删除了什么:temporary_assignments.rs 中标量覆写数组臂里一行错误的进程环境投影(`set_process_env` 调用),由 mark_exported 取代;无其他删除。净行数 +278/−1(4 文件,含新回归钉 223 行)。 Fixes #2963 Fixes #2964
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.
Refs #2944
Refs #2945
Refs #2946
Refs #2947
r79 hunt batch — four independent roots, one PR. Pins land first (fail-first on master
4f747412); the code changes follow in a second commit on this branch.What changes, per issue
#2944 —
set -aignored bylocal/readonlyinitialization.GNU:
set -asetsmark_modified_vars(flags.c:47, flags.c:167), applied by the scalar bind primitives only —bind_variable_internaltail (variables.c:3211-3212),bind_variable_value(variables.c:3366-3367).local's valued operands bind throughbind_variable_valuevia declare_internal (builtins/declare.def), and readonly's valued words bind throughdo_assignment_no_expand→bind_variable(builtins/setattr.def), whileset_var_attributecreates a missing variable throughbind_variable(name, NULL, 0)(setattr.def). Rubash:execute_declarealready emulated the mark (the #538 post-pass) butexecute_localhad no counterpart, andapply_readonly_argnever marked. Change: a valued-operand post-pass inexecute_localmirroring the declare one (valued scalar operands only — valueless locals perform no bind in GNU,make_local_variableonly; array creations and subscript operands bind through the array machinery, which never marks), plus the bind-shaped marks inapply_readonly_arg(creation short-circuit and the non-array valued path).#2945 —
set -awrongly marks arrays-x.GNU: the mark lives only in the scalar bind primitives above. Array creation (
make_new_array_variablevariables.c:2798,make_new_assoc_variablevariables.c:2851) and the compound path (do_compound_assignmentsubst.c:3441 →assign_array_from_stringarrayfunc.c:507) never mark. Rubash marked in two places GNU does not: the generic tail ofapply_shell_assignment_innermarked every shape including compound binds, and theexecute_declarepost-pass marked-a/-Acreation operands. Change: gate the assignment tail's mark on the bind not being a compound assignment, and skip the declare post-pass marking when the invocation carries-a/-A. The flaglessdeclare arr=(1 2)form keeps GNU's-axquirk (the valued word creates the name throughbind_variablebefore conversion) — pinned as a control.#2946 — associative assignment evaluated the subscript twice.
GNU:
assign_array_element_internal(arrayfunc.c:392-398) expands the subscript exactly once viaexpand_subscript_stringand hands the expanded key tobind_assoc_variable; an assignment word gets no whole-word expansion pass (general.c:480). Rubash ran the whole-word expansion over the assignment word (first evaluation, result discarded) and then expanded the raw subscript again inprepare_array_element_assignment_word(second evaluation — the one whose key was stored). Change: inexpand_command_word, attempt the assignment preparation before the whole-word pass for every associative element-assignment word, not only for the provably side-effect-free subset; when preparation resolves the word, the whole-word pass never runs. The now-unused side-effect predicate is removed. Indexed subscripts are untouched (preparation declines non-associative arrays) and the expansion form is untouched.#2947 — POSIX-mode
sourcediagnostic printed..GNU: builtins/source.def registers two builtins over one implementation —
source(source.def:23) and.(source.def:39) — and the diagnostic isbuiltin_error(_("%s: file not found"), x)(source.def:179) with the prefix taken fromthis_command_name, the invoked name (builtins/common.c:93-94). Rubash hardcoded the.spelling in the file-not-found arm of the source builtin. Change: use the invoked command name the executor already threads through, matching the sibling arms in the same function.本 PR 删除了什么
assoc_element_word_expansion_is_side_effect_freepredicate (command_prepare.rs) and its doc comment: its only call site was the gate described in [bug] Associative array assignment evaluates the subscript twice #2946 above; with preparation attempted first for the whole associative-assignment class, the predicate has no remaining consumer..in the source builtin's file-not-found format string.Net-line accounting
+a-corner pins): +167 / −61 across 7 files — src +149 / −61 (declare_local.rs +90, command_prepare.rs +20 / −61, setattr/apply.rs +21, temporary_assignments.rs +9 / −1 in effect, source.rs +7 / −1 in effect), tests +18 / −0.Pins (fail-first on master 4f74741, oracle = GNU bash 5.3.20)
tests/issue2944_allexport_local_readonly_regressions.rs— master: 4 passed / 6 failed (local, local -i, local -g, readonly, readonly compound, valueless readonly facets fail; all controls pass).tests/issue2945_allexport_array_no_export_regressions.rs— master: 4 passed / 6 failed (compound, assoc compound, empty compound, declare -a compound, declare -a scalar, append facets fail; controls incl. the flagless-declare quirk pass).tests/issue2946_assoc_subscript_single_eval_regressions.rs— master: 3 passed / 5 failed (plain, assoc_expand_once, nested, first-key, append facets fail; indexed/expansion/value controls pass).tests/issue2947_posix_source_diagnostic_regressions.rs— master: 4 passed / 2 failed (POSIXsourceform andsource -pfacets fail;.forms and default-mode controls pass).