Repository navigation
fix(executor): ${v:?${-x}} reports only the nested bad substitution - #3855
Merged
caomengxuan666 merged 1 commit intoNov 17, 2026
Merged
Conversation
…Refs #3502) GNU parameter_brace_expand_error (subst.c:8216-8239) expands the :? message word first; a bad substitution inside it reaches valid_brace_expansion_word's failure (subst.c:7583-7597, 10042-10057) and longjmps before the outer `name: word` report can run, so `${v:?${-x}}` prints only `${-x}: bad substitution` — never a trailing `v: ` line. The pre-scan now checks the whole word with braced_name_is_bad_substitution before parsing the :? operator, returning the bad-substitution result instead of falling into the operator path that emitted the spurious outer report.
Member
Author
|
【WIN-AGENT-AUDIT】i1 审计 — 建议:FAIL(#3855) PR #3855 第1轮 — 建议:FAIL 机制核查:
腿(逐项给数字与名字):
F 点(建议 FAIL):
续作记录:本轮未动代码(审计判 FAIL,返工属 g1 lane)。 未跑/VOID 的腿:
|
This was referenced Nov 17, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 17, 2026
… the scan can own (Refs #3864) The #3855 pre-scan gate judges every ${...} inner as a braced name and reports the scan's whole word with status 1, but GNU's bad substitution default (subst.c:10276-10288) reports the WORD BEING EXPANDED with the error class of the context. The scan may only emit that verdict when it coincides with the real expansion's, so the gate now defers to the real expansion when (a) the word is a compound assignment value — GNU expands elements individually (arrayfunc.c:557) and names the element word, which the scan's whole-word display cannot name (issue3500); (b) the name head is a $'...' literal the real expansion decodes — subst.c:7583 judges the extracted NAME (issue2650); (c) the verdict is POSIX-fatal — subst.c:10285-10286 FORCE_EOF when POSIX + non-interactive + compat > 43, which status 1 cannot express (audit B4-F08). All seven #3502 pins and the #3869 funsub pins are preserved by construction: no deferral fires on their words. UNVERIFIED-BY-CAPTAIN: no build/test executed in this lane (build chain down); head census re-run parked for the captain.
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
… the scan can own (Refs #3864) ## Summary Refs #3864. PR #3855 added a `braced_name_is_bad_substitution(inner)` check to the `parameter_expansion_error_in_word_context` pre-scan so a bad substitution inside a ` :?` message word surfaces as the inner error (rubash#3502: `${v:?${-x}}` prints only `${-x}: bad substitution`). The check judges the whole `${...}` inner as a braced name and reports the scan's whole word with status 1 — but the scan may only emit that verdict when it coincides with what the real expansion would report. Where it does not, the scan pre-empts the correct diagnostic: - Compound assignment values (issue3500, whole stem): GNU expands elements individually (`arrayfunc.c:557 expand_compound_array_assignment`) and the diagnostic names the element word (`\\[0\\]=${-x}`); the scan names the raw parenthesised value. - `$'name'` extquote names (issue2650): `subst.c:7583 valid_brace_expansion_word` judges the extracted NAME; the real expansion decodes `$'x1'` to `x1` in a quoted context, where the gate on the raw literal misjudges it. - POSIX fatal class (audit B4-F08): `subst.c:10285-10288` makes a bad substitution FORCE_EOF when POSIX + non-interactive + compat > 43; the scan's status 1 downgrades it to DISCARD. The funsub faces (issue2763/issue2761/issue3092/issue3823, golden_funsub_valsub, the arithmetic-for CLI case) are already fixed by #3869, which exempts funsub bodies at the top of this same scan loop; this PR does not touch that exemption. ## Repair The gate now fires only when the scan's verdict coincides with the real expansion's: it defers (returns nothing, letting the real expansion report) when any of these holds — 1. the scanned word is (or contains) a compound assignment value (parser compound marker, or a leading `(`): GNU's diagnostic is per-element, which the scan's whole-word display cannot name; 2. the span's name head is a `$'...'` literal that `resolve_dollar_quoted_parameter_name` decodes: the gate must judge the decoded name; 3. the POSIX-fatal predicate holds (POSIX mode, non-interactive, `compatibility_level > 43`, mirroring the fatal arm in `command_execute.rs`): the scan's status 1 cannot express FORCE_EOF. Everything else is unchanged: the gate still fires for bare bad names (`${-x}`, `${}`, `${(M)y}`), still pre-empts a later `:?` error left-to-right, and still fires inside `:?`/`:-` operator-word recursions — so all seven #3502 pins and the #3869 funsub pins keep passing by construction. ## What this PR removes Nothing from the product surface: the #3855 gate check stays; only its three over-broad firing slices are deferred to the real expansion. No new diagnostic text, no new error class. ## Validation **UNVERIFIED-BY-CAPTAIN** — no build or test was executed in this lane: the build chain is down (X299 tunnel refused, Simular box wallet empty, local build banned: MemAvailable ~503M, below the 1.5G gate). `cargo test` / `cargo check` / lib+base alignment / `RUSTFLAGS="-D warnings"` check are all parked; the captain re-runs the head census after the chain recovers. - New nails `tests/issue3864_parameter_errors_regression.rs` (11 tests): issue3500 element words (indexed/assoc/nested/valid guard), issue2650 extquote top-level + bare forms, POSIX fatal + compat43 guard, funsub-valsub shapes, #3502 inner-only + pin-7 ordering guards. Written fail-first, before the repair; fail-first is by code analysis, not execution (see above). - GNU oracle probes (local `/bin/bash` 5.2.21; stems already carry 5.3.20 verification): `"[${$'x1'}]"` -> `[hello]`; `a=([0]=${-x})` -> `\\[0\\]=${-x}: bad substitution` rc 1; POSIX `echo ${}` -> fatal, no ALIVE, rc 1; `${v:?${-x}}` -> only `${-x}: bad substitution` rc 1. - `rustfmt --check` clean on both touched files. - Evaluation note: reverting #3855 outright was considered and rejected — it would reopen #3502 (7 pins). The scoped repair keeps #3502 green while clearing the mechanically attributable clusters. Three singles in #3864 (issue2029, issue2771, issue2761 x2) have no `${` span in their scripts that can trip the gate, so no `parameter_errors.rs` change can clear them; they are recorded in the lane REPORT as unattributed (likely census flakes / other-window commits) for the captain's census re-run to confirm. ## Captain review (PASS, merged) Original head 19159b6, captain-extracted from its CI logs: census total 79 (era baseline), issue3500 19/19, own pins issue3864 11/11, goldens exactly the two baseline names; the darwin leg was cancelled with zero steps (never ran, not a red). Merge-shape head 0a73b4f (update-branch over master 0863639; the only master-side touch of parameter_errors.rs since the merge-base was PR #3871's +6/-2 arith-label hunk near line 1417, ~1000 lines from this PR's hunks), captain-extracted: - issue3500 19/19 PASS, issue3864 11/11 PASS, issue2650 10/10, issue2763 6/6, issue201 2/2, issue2771 5/5, audit stems 40/40. - Census total 81, goldens exactly the two baseline names. - Two non-blocking cells, both adjudicated churn: the CLI leg's sole failure is c_command_keeps_named_coproc_output_fds_distinct (2 PASS / 2 FAIL across four era heads, uncorrelated with any diff), and census cell issue2029 head_pipe_fold_leaves_the_remainder is FAIL here but PASS on both the original head and on PR #3870's head (which carries #3855 without this fix) — not owned by this change. Fail-first basis (stated honestly): the lane's 11 pins were written pre-fix but not executed pre-fix (no build route); their fail-first rests on code analysis, corroborated by the tip census showing the same shapes red before this PR and green after. What this removes: the unscoped #3855 gate call in parameter_expansion_error_in_word_context — the scan emitted whole-word status-1 verdicts for compound values, $'...' name heads and the POSIX-fatal class. It is replaced by the deferral-aware gate; each deferral restores the pre-#3855 behavior for that slice. No other behavior is deleted.
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.
Fixes #3502
Summary
${v:?${-x}}printed two diagnostics —${-x}: bad substitutionand a spuriousv:line — where GNU prints only the first.GNU ordering (
subst.c):parameter_brace_expand_error(subst.c:8216-8239) expands the:?/?message word viaexpand_stringbefore it canreport_error("%s: %s", name, temp).valid_brace_expansion_word(subst.c:7583-7597) and takes the bad-substitution fallback (subst.c:10042-10057,10272-10288), which longjmps — the outerv:report never runs.Rubash's diagnostic pre-scan parsed the
:?operator first and reported the outername: wordform, emitting the extrav:line after the inner bad substitution had already been reported.Fix: in the pre-scan (
parameter_errors.rs), beforeparse_parameter_error_operator, check the whole inner word with the existingbraced_name_is_bad_substitution(thevalid_brace_expansion_wordport). A bad-substitution word now returns the bad-substitution result immediately — display subject is the whole:?message word (pre ${-x} post: bad substitution, matching GNU'sexpand_stringgranularity), status 1 — so the operator path that producedv:is never reached.What this PR removes
The spurious second diagnostic line for this operand family; nothing else.
Validation
tests/issue3502_question_error_bad_substitution_word.rs: 7 tests, all pass on head.6ecb7cab: 5 failed / 2 passed — red set is exactly the bad-substitution-ordering assertions; the 2 green are preserved-behavior guards (nested${x:?inner}still reportsx: innerrc 127;${v:?${-}}still reportsv: <flags>rc 127).cargo test --lib: head 1376/1/4 vs base 1376/1/4, failure-name set difference empty (shared failureapi::consumer_tests::issue2084_session_end_restores_host_process_statereproduces identically on base — environmental).RUSTFLAGS="-D warnings" cargo check --all-targets: clean.check-marker-literals.pyOK;check-utf8-boundary-hygiene.shclean./usr/local/bin/bash,9c465866) script-file probes, 12 shapes (:?/?/:-/=/+/%operators, unset/empty/setv, whole-word and fragment bad substitutions, nested:?, flags parameter, bad-substitution-before-?ordering): stdout+stderr+rc byte-identical modulo the program-name prefix.