Skip to content

printf locale faces read the guard; declare subscript operands unmarked (Refs #2979, #2980) - #2996

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/2979-2980
Nov 7, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/2979-2980

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Lane delivery for two captain-filed residuals. One commit per issue; this PR stays draft for captain verification (UNVERIFIED-BY-CAPTAIN; full evidence in the lane REPORT).

Refs #2979
Refs #2980

printf locale faces (first commit)

printf's remaining locale faces read the process environment while the character-constant face reads the dispatch funnel's ShellLocaleGuard: byte_mode for %S/%C (value.rs), the \u/\U encode gate and the %q/%Q quoting walks (escape.rs), and decimal_point(). Plain in-script assignments mask the split because the assignment funnel mirrors the locale family into the process env (rubash#1531); a store-side write such as printf -v LC_ALL C bypasses the funnel and the faces diverge from GNU and from each other (%d "'é" said 195 while \u00e9 still encoded UTF-8). All printf multibyte reads now share locale::is_multi_byte_active(); the guard carries a second slot with the LC_NUMERIC category chain (LC_ALL > LC_NUMERIC > LANG, GNU locale.c:345) and decimal_point() resolves through it. GNU anchors: locale.c:185 set_locale_var, printf.def:502/532, snprintf.c:442-443.

declare subscript allexport mark (second commit)

Under set -a, declare arr[0]=x printed declare -ax; GNU prints -a. execute_declare's allexport post-pass derived the base name and marked it, but a subscript operand binds through assign_array_element, which never applies the mark_modified_vars mark (variables.c:3211-3212). The pass now skips subscript operands, matching execute_local's post-pass. Existing-pin audit: no pin depended on the subscript -ax shape; all standing -ax expectations are whole-name shapes and stay pinned as controls.

Self-verification (lane-run, captain to re-check)

  • Pins fail-first: issue2979 stem 8 failed / 2 control passed; issue2980 stem 7 failed / 1 control passed. After: 11 passed / 0 failed and 8 passed / 0 failed.
  • Full lib: 1188 passed / 0 failed / 4 ignored — identical to base b3e4ff8.
  • RUSTFLAGS="-D warnings" cargo check --locked --lib --bins: rc=0.
  • scripts/check-utf8-boundary-hygiene.sh: clean. rustfmt clean on every touched file.
  • Neighbourhood (51 printf/declare/locale stems): 49 green; the only failing names are issue1100's 5 and issue353's 4, byte-identical name sets on base (stash-verified) — pre-existing.
  • Post-change product probes byte-identical to GNU bash 5.3.20 on the split cell and the declare cells.

No public API surface added (new locale helpers are pub(crate)); docs/api-ledger.md and src/lexer/continuation.rs untouched.

byte_mode (%S/%C width and precision), the \u/\U encode gate, the %q/%Q quoting walks and decimal_point() read the process environment, while the character-constant face (rubash#2965) reads the dispatch guard's variable-table locale. A store that bypasses the assignment funnel (printf -v LC_ALL ...) left table and process env split, and the faces disagreed with each other and with GNU: GNU keeps one current locale per category via the sv_locale watchers (locale.c:185 set_locale_var, locale.c:345 get_locale_var).

All printf multibyte reads now go through locale::is_multi_byte_active(); ShellLocaleGuard additionally carries the LC_NUMERIC category chain (LC_ALL > LC_NUMERIC > LANG) in a second slot, and decimal_point() resolves through it. The global is_utf8()/is_multi_byte() env reads are unchanged for non-builtin consumers.

Pins: tests/issue2979_printf_locale_guard_faces_regressions.rs (fail-first 8 failed / 2 control passed; after: 11 passed / 0 failed).
Under set -a, declare arr[0]=x printed declare -ax while GNU prints declare -a, at top level and inside functions. The operand binds an element through assign_array_element, which never applies the mark_modified_vars mark; the mark belongs to whole-name bindings (variables.c:3211-3212). execute_declare's rubash#538 post-pass split the operand on '[' and marked the base name anyway. It now skips subscript operands, matching execute_local's post-pass, which already skipped them. Explicit declare -x arr[0]=x keeps -ax (the builtin's own attribute application, probed against GNU).

Existing-pin audit before the change: no pin depended on the subscript -ax shape; every standing -ax expectation is a whole-name shape (issue2964 compound, issue2945, issue2944 -arx, issue2963 scalar binds) and is pinned as a control in the new stem.

Pins: tests/issue2980_declare_subscript_allexport_regressions.rs (fail-first 7 failed / 1 control passed; after: 8 passed / 0 failed).
@caomengxuan666
caomengxuan666 merged commit a3416e8 into master Nov 7, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant