Skip to content

fix(trap): ERR-trap nested-context semantics — collapse suppression, flat-region fire, return attribution (rubash#720) - #831

Merged
caomengxuan666 merged 4 commits into
masterfrom
fix/720-713
Oct 18, 2026
Merged

caomengxuan666 merged 4 commits into
masterfrom
fix/720-713

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes the three fixable faces of #720 (form 3 stays tracked there); second #713 pass ships in the same train: the nested-context inheritance/isolation audit doc, the probe harness extension, and two defect tickets filed from it (#825, #826).

Forms fixed (all byte-pinned against WSL GNU bash 5.3.0(1), stdin oracle)

Form 1 — ( (false) ) fired 3, GNU fires 2 (nested subshell over-fire)

GNU marks a user subshell's WHOLE body CMD_NO_FORK when it is a single subshell command (execute_cmd.c:1799-1806 in the vendored 5.3 mirror) and dispatches it in place (execute_cmd.c:662-663) — no second make_child/wait_for, so the middle frame never observes the failure and its :769 run_error_trap never runs. Rubash's forkless ( ) runs every body in place, so its middle frame "waited" and over-fired. Fix: a subshell_fork_collapse executor flag scoped to exactly that body shape (node form in execute_subshell_command_with_redirects; flat form at the ast_exec region open), consulted by the aggregate ERR site and by the set -e early conversion. Non-collapsed middles still fire (( (false); false ), ( { (false); } ) keep the middle fire — probes included).

Form 2 — f() ( false ); f fired 2, GNU fires 3 (flat f() ( ) region under-fire)

The body subshell's completion ERR adjudication belongs to the frame that waited for its fork (execute_cmd.c:756-778 — no &&/|| exemption there; $LINENO = the subshell's own ) line per execute_cmd.c:696; BASH_COMMAND = the region's print_cmd text fixed by the :703-710 fork preamble). The forkless flat region had no boundary fire. Fix: the parser stamps the region opener's end_line with the ) line (parse_parenthesized_function_body), and every flat-region close path runs close_flat_region_err_adjudication after the parent-state restore. The call-site fire now reports ( false ) like GNU instead of f.

Form 4 — until false; do f; done with f(){ return 7; } printed ERR:1/exited 1, GNU prints ERR:7/exits 7

A return N unwinding through dispatch is the builtin's own completion (return.def:112-115 jumps only for an out-of-range count); the function boundary stamps exit_code = N and the CALL's gate adjudicates. The dispatcher gate was firing with the loop condition's stale status and consuming the Return unwind. Fix: the gate passes Err(Return) through in function/source context; the boundary stamps; the call's gate fires with 7 and converts under set -e.

Not in this PR

Form 3 (cat <(false), the process-substitution copy path) is the PR #715 read/procsub reaping area — stays tracked in #720.

#713 second pass (audit, not fixes)

Verification

@caomengxuan666

Copy link
Copy Markdown
Member Author

CR verdict: REQUEST-CHANGES

The three claimed forms are correct and byte-pinned (I re-derived every transcript independently against WSL GNU 5.3.0(1) via the stdin oracle; 12/12 new tests + issue797 8/8 pass on my own runs). What blocks merge is R1: the PR's central coverage claim — "every region close path runs close_flat_region_err_adjudication after the parent-state restore" (commit message; ast_exec.rs close-path comments) — is falsified by three reachable flat-region exits that run no close at all (neither state restore nor form-2 fire). All three are byte-divergent vs GNU and byte-identical to base db4aaf7b (= origin/master, verified), so they are not regressions — but they are inside the mechanism family this PR owns, one is the PR's own cited probe, and none is carved out the way form 3 is. Merge as-is would enshrine a false "full coverage" statement.

R1 — three flat-region close paths have no close: missed form-2 fire + permanent ShellState/$BASH_SUBSHELL leak (pre-existing, untracked)

All repros standalone, GNU 5.3.0(1) stdin vs this PR's rubash -c, byte-exact:

(a) and_or body — g() ( false && true ); g (src/executor/ast_exec.rs:1217-1264, the and_or_list arm ends index += 1; continue without any subshell_end check):

GNU: E sub=0 cmd=[( false && true )] / E sub=0 cmd=[( false && true )] / rc=1 top=0
PR : E sub=1 cmd=[false]                              / rc=1 top=1

GNU fires the region close AND the call with the region text — this is exactly the probe your own maybe_run_error_trap_for_flat_region doc (trap_exec.rs:1272-1275) cites as firing ("no &&/|| exemption at :769, probe: f() ( false && true ); f fires"). The implementation never reaches the close. Worse, top=$BASH_SUBSHELL stays 1 for the rest of the session — the saved ShellState (env, aliases, functions, depth) wholesale-leaks into the parent on this path (pre-existing; the PR's flag itself is not leaked — collapsed regions close normally).

(b) pipeline body, multiline — f() (\n true | false\n)\nf (src/executor/ast_exec.rs:1319-1324, execute_simple_pipeline Ok(Some(next_index)) => { index = next_index; continue; }):

GNU: E sub=1 lin=2 cmd=[false] / E sub=0 lin=3 cmd=[( true | false )] / E sub=0 lin=4 cmd=[( true | false )] / rc=1 top=0
PR : E sub=1 lin=2 cmd=[false] / E sub=1 lin=4 cmd=[false]                                           / rc=1 top=1

Region close fire missing; the call fire reports stale cmd=[false] at leaked depth; top leaks.

(c) return unwind — f() ( x=v; return 4 ); f (catch-alls src/executor/ast_exec.rs:1316/1362/1523 return Err without tearing the region down; Err(Return) now passes the R4 gate by design and hits these):

GNU: E sub=0 cmd=[( x=v; return 4 )] / E sub=0 cmd=[( x=v; return 4 )] / rc=4 top=0 x=[]
PR : E sub=1 cmd=[return 4]           / rc=4 top=1 x=[v]

x=v leaks across the subshell boundary into the parent — a fork-isolation violation in the exact shape family form 2 claims, and GNU's two ( return 4 ) fires are both missing.

Ask (either is fine): cover the three paths — close_subshell_region_if_ended! on the (a)/(b) arms plus a region-teardown catch for Err(Return)/catch-all unwinds — or keep them out of scope explicitly: file tickets for all three (nothing in #720 or the tracker covers them today; only form 3 has a carve-out) and correct the "every region close path" claim in the commit message and the close-path comments so the permanent record matches the implementation.

R2 (nit) — dead GNU anchor return.def:112-115

Cited in the commit message, src/executor/command_dispatch.rs:267, and the test docstring. The vendored mirror's builtins/return.def is 76 lines total — 112-115 does not exist. The actual mechanism: return_builtin (return.def:57-76, get_exitstat + sh_longjmp (return_catch, 1) under return_catch_flag), with the out-of-range/posix clamp in builtins/common.c get_exitstat. The behavior is right (both GNU shapes byte-match including ERR:7/exit 7/cmd=[return 7]); only the anchor is wrong. Since file:line anchors are load-bearing in this codebase, please fix the citations.

R3 (nit) — CHANGELOG

Repo convention adds an Unreleased entry per PR (#754 did in 2d8dc03, #807 in 200771b); this PR touches none.


Verified clean (independently re-run, not taken from the PR description)

No merge from my side; the PR worktree D:/repo/rubash-cr-831 (branch cr-831) is untouched apart from build artifacts.

caomengxuan666 added a commit that referenced this pull request Oct 18, 2026
…bash#720)

The CR round overturned the "every region close path adjudicates" claim
with three reachable flat-region exits that neither restored the saved
parent state nor ran the :769 fire; probing found a fourth (brace-group
Ok(true)) and the catch-alls of the four early dispatch arms shared the
same leak. All fixed structurally now:

- and_or_list / brace / simple_pipeline / main-dispatch (plus the
  pipeline, inverted, time, background and time-prefixed arms): the
  fall-through and Ok-arms run close_subshell_region_if_ended!, and
  every catch-all closes before the unwind crosses the boundary — the
  saved parent state (variables, subshell_depth, trap table) can no
  longer leak across `f() ( ... )` exits.

- `return N` inside a flat region is absorbed at the boundary as a
  plain status-N completion: GNU's return.def:57-76 return_builtin
  longjmps the CHILD's own return_catch and the child exits N; the
  parent observes the wait status and the function continues after the
  region (the node-form boundary already documented this absorption).
  `f() ( x=v; return 4 ); f` now fires twice with the region text
  `( x=v; return 4 )` and x stays clean — the first cut leaked x=v and
  reported a stale BASH_SUBSHELL.

- lastpipe `exit N` inside a region is likewise a child completion
  (the "current shell" of the region's stand-in), absorbed instead of
  unwinding to the top level; the top-level propagation keeps the #74
  G2 semantics.

- and-or non-last elements no longer fire the ERR trap: GNU marks every
  &&/|| operand CMD_IGNORE_RETURN except the finally-executed one
  (execute_cmd.c:2943; execute_cmd.c:1000 refuses on ignore_return) —
  `g() ( false && true ); g` fired `false` where GNU fires only the
  region and the call.

CR nits: the return.def anchor corrected (:112-115 was dead — the
mechanism is return.def:57-76 return_builtin + get_exitstat,
builtins/common.c); CHANGELOG Unreleased entry added.

Tests: +5 cases in tests/issue720_err_trap_nested_context_regressions.rs
(17 total), each the literal WSL GNU bash 5.3.0(1) transcript. Final
14-form battery identical to GNU; goldens 74/74, issue797 8/8, audit
harness 45 cases (same 4 known findings, none new), full-suite
no-fail-fast comparison against the stashed origin/master baseline:
zero new failures.
@caomengxuan666

Copy link
Copy Markdown
Member Author

CR round 2 — addressed (e2fcb78, rebased on a87f826/#823)

Coverage — accepted in full, and widened. All three cited paths reproduce and are fixed, plus two more of the same class found while enumerating the walker:

path probe status
and_or_list fall-through + catch-all (ast_exec ~1217-1264) g() ( false && true ); g closed + fire; GNU 2-fire transcript pinned
execute_simple_pipeline Ok(Some) (ast_exec ~1319-1324) f() (\n true | false\n) closed + fire; GNU 3-fire transcript pinned
main-dispatch catch-all (~1523) f() ( x=v; return 4 ); f closed + fire; GNU transcript pinned, x=pre
brace-group Ok(true) (found in the same sweep) k() ( { false; } ) closed + fire; GNU 3-fire transcript pinned
the four early dispatch arms' catch-alls (inverted / time / background / time-prefixed — fall-throughs already had the macro, catch-alls did not) — close-before-return, structurally uniform

The structural form: every catch-all in the walker now runs close_subshell_region_if_ended! before return Err (a no-op outside a region), and every fall-through/Ok arm runs it before its continue — no per-arm enumeration left open.

State leak — zero. return N inside a flat region is now absorbed at the boundary as a plain status-N completion, matching GNU (return.def:57-76 return_builtin sh_longjmps the CHILD's own return_catch and the child exits N; the parent observes the wait status and the function continues after the region — the node-form boundary in execute_subshell_command_with_redirects already documented this absorption). f() ( x=v; return 4 ); f fires twice with the region text ( x=v; return 4 ) and x stays pre. A dedicated leak probe (BASH_SUBSHELL after and-or/return/paren sequences) is byte-identical with GNU.

Two adjacent classes fixed in the same sweep:

  • lastpipe exit N inside a region (m() ( true | exit 3 ), shopt -s lastpipe): the "current shell" there is the region's forked stand-in — absorbed as a status-3 completion (GNU: two fires, rc=3); the top-level propagation keeps the gnu-compat G2: lastpipe 退出码(14 vs 0) #74 G2 semantics.
  • and-or non-last elements fired the ERR trap (g() ( false && true ); g fired false where GNU fires only region+call): GNU marks every &&/|| operand CMD_IGNORE_RETURN except the finally-executed one (execute_cmd.c:2943; :1000 refuses on ignore_return) — execute_and_or_list_command now keeps the and_or marker on non-last elements and clears it only on the last.

Nits — both done. The return.def:112-115 anchor replaced with the real mechanism (return.def:57-76 return_builtin, get_exitstat in builtins/common.c, sh_longjmp :71-72, invalid-argument arms :67-69/:73-75). CHANGELOG Unreleased gained a 修复 entry for the whole #720 train.

Verification: tests/issue720_err_trap_nested_context_regressions.rs now 17 cases (5 new, each the literal WSL GNU bash 5.3.0(1) stdin-oracle transcript) — 17/17. Goldens + snapshots 74/74. issue797 (#807 ignore shapes) 8/8. Audit harness 45 cases — same 4 known findings (#825/#826), none new. Full-suite --no-fail-fast against the stashed origin/master baseline: zero new failures (the earlier flaky windows_listing_cache did not recur; the ~30 pre-existing local helper/external-process failures are identical both sides). Final 14-form differential battery vs WSL GNU: IDENTICAL.

@caomengxuan666

Copy link
Copy Markdown
Member Author

CR round 2 — verified, verdict: APPROVE-WITH-NITS

All checks re-run independently (WSL GNU 5.3.0(1) stdin/file oracle vs e2fcb78f binary, my own scripts, not the author's):

Coverage (①) — confirmed byte-identical, all five shapes:

  • g() ( false && true ); g → 2 fires [( false && true )] sub=0, top=$BASH_SUBSHELL=0 (was: 1 fire + leak)
  • f() (\n true | false\n)\nf → 3 fires, LINENO 5/6/7 exactly GNU's (was: 2 wrong)
  • f() ( x=v; return 4 ); f → 2 fires [( x=v; return 4 )], x stays pre (was: 1 fire + leak)
  • k() ( { false; } ) → 3 fires incl. both [( { false; } )] (new sweep find, matches GNU)
  • early-dispatch arms: inverted ! shape byte-matches; lastpipe m() ( true | exit 3 ) → 2 fires rc=3, and top-level true | exit 3 under set -e still exits 3 (gnu-compat G2: lastpipe 退出码(14 vs 0) #74 G2 preserved)

State leak (②) — zero, byte-proven: BASH_SUBSHELL sequences after and_or/return/brace/plain regions (s1=0 / in=1 / s2=0) all identical with GNU; x=[pre] held.

Walker completeness (③) — the round-2 structural rule is sound (every catch-all closes before return Err, every fall-through closes before continue), and my independent enumeration of the walker's exit paths finds only two residual uncovered returns, both pre-existing and non-blocking:

Also pre-existing (base-identical, diagnostic-only, note for the tracker): ( return 4 ) in a subshell — GNU is silent (rc=2, no message), rubash prints return: can only 'return' from a function or sourced script; status and ERR-fire parity hold.

and_or marker change (pipeline_exec.rs) — parity-checked: false && false, true && false, false || true, false && true at top level and the until false || true condition all byte-match GNU (non-last silent, last-element and loop-condition semantics intact).

Suites (④) — pass on my runs: issue720 17/17, issue797 8/8, audit harness 45 cases / same 4 known divergences (#825/#826). fmt clean.

Hygiene (⑤) — clean: round-1 content is byte-identical after the rebase onto a87f826 (diffed d297f7b2 vs 0d87020e per trap file — only #804/#823 rebase context differs); round 2 touches exactly the five described files + CHANGELOG (R3 done, entry accurate). Full cargo test --no-fail-fast failure profile is identical suite-by-suite and count-by-count to base a87f826 (12 suites, same numbers each) — zero new failures, zero fixed. One counting nit: the "goldens 74/74" phrasing — my run still shows regression.rs at 73 passed / 1 failed on BOTH sides (the known pre-existing failure), so the claim's arithmetic doesn't match what I measure, though no regression exists. The new return.def anchor ranges bracket the real code but are loose (sh_longjmp is :70, not :71-72; posix arm :66-67) — cosmetic, nothing like the old dead anchor.

No merge from my side; worktree D:/repo/rubash-cr-831 untouched apart from build artifacts.

…flat-region fire, return attribution (rubash#720)

Three facets of the set -E ERR adjudication at subshell boundaries, all
byte-pinned against WSL GNU bash 5.3.0(1) (stdin oracle):

- Form 1, nested subshell fire count: GNU marks a user subshell's WHOLE
  body CMD_NO_FORK when it is a single subshell command
  (execute_cmd.c:1799-1806) and dispatches it in place — no
  make_child/wait_for — so the middle frame of ( (false) ) never
  adjudicates and GNU fires twice, not three times. Rubash now scopes a
  subshell_fork_collapse flag around exactly that body shape (node form
  in execute_subshell_command_with_redirects, flat form at the ast_exec
  region open) and skips the aggregate ERR adjudication under it,
  including the set -e early conversion (command_execute.rs).

- Form 2, f() ( ) flat region: the completion ERR fire belongs to the
  frame that waited (execute_cmd.c:756-778, no &&/|| exemption, LINENO
  = the subshell's close-paren line per execute_cmd.c:696, BASH_COMMAND
  = the region's print_cmd text per the :703-710 fork preamble). The
  forkless region had no boundary fire — f() ( false ); f fired twice
  where GNU fires three. The parser now stamps the opener's end_line
  with the ) line, and every region close path runs
  close_flat_region_err_adjudication after the parent-state restore.

- Form 4, return-in-until attribution: a return N unwinding through
  dispatch is the builtin's own completion (return.def:112-115); the
  dispatcher gate fired with the loop condition's stale status and lost
  the N. The gate now passes Err(Return) through to the function/source
  boundary, which stamps exit_code = N before the call's own gate
  adjudicates — ERR:7 / exit 7, matching GNU.

Form 3 (cat <(false), the procsub copy path) stays tracked in #720 —
it is the PR #715 read/procsub reaping area, not a trap-context fix.

Companion #713 second pass: docs/audit/context-inheritance.md (the
context x property inheritance/isolation table), nested-context-probes
extended 24 -> 45 cases, and two new defect tickets found by the audit
(#825 -T DEBUG not inherited into $( ), #826 compound
redirection-failure diagnostic bypassing the ordered fd table).

Tests: tests/issue720_err_trap_nested_context_regressions.rs (12 cases,
one per form/edge, GNU transcripts pinned). Goldens 70/70, issue797
8/8, full-suite bidirectional comparison against origin/master shows no
new failures.
…bash#720)

The CR round overturned the "every region close path adjudicates" claim
with three reachable flat-region exits that neither restored the saved
parent state nor ran the :769 fire; probing found a fourth (brace-group
Ok(true)) and the catch-alls of the four early dispatch arms shared the
same leak. All fixed structurally now:

- and_or_list / brace / simple_pipeline / main-dispatch (plus the
  pipeline, inverted, time, background and time-prefixed arms): the
  fall-through and Ok-arms run close_subshell_region_if_ended!, and
  every catch-all closes before the unwind crosses the boundary — the
  saved parent state (variables, subshell_depth, trap table) can no
  longer leak across `f() ( ... )` exits.

- `return N` inside a flat region is absorbed at the boundary as a
  plain status-N completion: GNU's return.def:57-76 return_builtin
  longjmps the CHILD's own return_catch and the child exits N; the
  parent observes the wait status and the function continues after the
  region (the node-form boundary already documented this absorption).
  `f() ( x=v; return 4 ); f` now fires twice with the region text
  `( x=v; return 4 )` and x stays clean — the first cut leaked x=v and
  reported a stale BASH_SUBSHELL.

- lastpipe `exit N` inside a region is likewise a child completion
  (the "current shell" of the region's stand-in), absorbed instead of
  unwinding to the top level; the top-level propagation keeps the #74
  G2 semantics.

- and-or non-last elements no longer fire the ERR trap: GNU marks every
  &&/|| operand CMD_IGNORE_RETURN except the finally-executed one
  (execute_cmd.c:2943; execute_cmd.c:1000 refuses on ignore_return) —
  `g() ( false && true ); g` fired `false` where GNU fires only the
  region and the call.

CR nits: the return.def anchor corrected (:112-115 was dead — the
mechanism is return.def:57-76 return_builtin + get_exitstat,
builtins/common.c); CHANGELOG Unreleased entry added.

Tests: +5 cases in tests/issue720_err_trap_nested_context_regressions.rs
(17 total), each the literal WSL GNU bash 5.3.0(1) transcript. Final
14-form battery identical to GNU; goldens 74/74, issue797 8/8, audit
harness 45 cases (same 4 known findings, none new), full-suite
no-fail-fast comparison against the stashed origin/master baseline:
zero new failures.
…-free — failglob verdicts stay in the child (753.11)

The gate expands the async command's words in the PARENT as an
eligibility probe (background_direct_external_command ->
expand_command_words); on failglob that probe (a) printed `no match` in
the parent — the wrapper fallback's child re-reported it, doubling the
diagnostic on the `&` line — and (b) armed the parent-side expansion
latches (command_expansion_failed, evalerror_pending,
evalerror_failglob_pending, exit_code=1), whose reader-level discard
swallowed the rest of the launch line (`set -- /no/such/*.zzz & echo
BG_after` lost its echo entirely). GNU expands the forked child's words
inside the child: the parent never observes the verdict, the diagnostic
prints once, and the launch line's remaining commands run.

Fix: the probe runs under an expansion_probe_active flag —
report_failglob stays silent while it is set — and the Err path
restores the expansion latches and the pre-probe exit code before
falling back to the wrapper, whose child reports exactly once.

Attribution note: this is a master regression from the #809 train
(28744c8 + CR rounds), reproduced on 5d51376 WITHOUT any #831 change;
the bisect is 0d87020/e2fcb78f PASS -> c0005ff (rebase onto
5d51376) FAIL. It surfaced on this branch only because the rebase
picked the regression up. The CR-round-2 collapse hypothesis does not
hold — the failing shape is a background `&`, not `( (… ) )`, and the
collapse flag is inert without a flat region.

Tests: tests/regression.rs issue_753 suite 17/17 (case_11 included);
failglob x collapse on/off battery (( (… ) ) collapsed, multi-command
uncollapsed, f() ( ) flat, `&` gate, plain ( )) byte-identical with WSL
GNU 5.3.0(1); issue720 17/17, issue797 8/8, goldens 74/74, audit
harness 45 cases (same 4 known findings); ERR 14-form battery
identical.
@caomengxuan666

Copy link
Copy Markdown
Member Author

CR round 3 — case_11 fixed (63f40f3); attribution corrected: master regression, not the collapse flag

Bisect (case_11 issue_753::case_11_containing_boundaries_stay_contained):

commit base case_11
0d87020 (round 1) a87f826 PASS
e2fcb78 (round 2) a87f826 PASS
5d51376 (current master, no #831 changes) — FAIL
c0005ff (round 2 rebased onto 5d51376) 5d51376 FAIL (inherited)

The collapse-mechanism hypothesis does not hold: the failing shape is a background & (set -- /no/such/*.zzz & echo …), not ( (…) ); the subshell_fork_collapse flag is inert without a flat region, and round 2 passed case_11 before the rebase. The failure is a master regression from the #809 train (28744c8 exec background simple externals directly + its CR rounds), which the rebase onto 5d51376 picked up.

Mechanism (confirmed in code): background_direct_external_command expands the async command's words in the PARENT as an eligibility probe (expand_command_words, Err(_) => return None). On failglob that probe (a) printed no match parent-side — the wrapper fallback's child re-reports it → the doubled line-4 diagnostic — and (b) armed the parent-side expansion latches (command_expansion_failed, evalerror_pending, evalerror_failglob_pending, exit_code = 1), whose reader-level discard swallowed the rest of the launch line — BG_after rc=0 never printed. GNU expands the forked child's words inside the child: one diagnostic, launch line intact.

Fix (63f40f3): the probe is now side-effect-free — it runs under expansion_probe_active, report_failglob stays silent while set, and the Err path restores the expansion latches plus the pre-probe $? before falling back to the wrapper, whose child reports exactly once.

Verification:

  • tests/regression.rs issue_753 suite 17/17 (case_11 included).
  • failglob × collapse on/off battery — ( ( /no/such/*.zzz ) ) collapsed, ( ( … ); : ) uncollapsed, f() ( … ) flat, the & gate shape, plain ( … ) — all byte-identical with WSL GNU 5.3.0(1), with an ERR trap armed to also cover the trap×failglob face.
  • issue720 17/17, issue797 8/8, goldens + snapshots 74/74, audit harness 45 cases (same 4 known findings), ERR 14-form battery identical — the three main fixes and the CR-2 round do not regress.

@caomengxuan666

Copy link
Copy Markdown
Member Author

CR round 3 — 63f40f3 (probe side-effect fix): verdict APPROVE

All four review points re-verified independently (WSL GNU 5.3.0(1) oracle, own scripts):

① Flag mechanism — boundaries tight, no leak paths. expansion_probe_active is set immediately before expand_command_words and cleared unconditionally immediately after (compound_exec.rs:835-837, nothing between set and clear can early-exit); the sole consumer is report_failglob's early return (command_prepare.rs:3203-3208) — non-probe failglob reporting is untouched, confirmed live: foreground set -- /no/such/*.zzz reports once with rc=1 and the region shape f() ( set -- … ) reports once from the child exactly as before. Nesting/recursion cannot reach the flag: the gate's pre-filters route every substitution-bearing word ($(, backtick, :=, param-assign raw scan + parameter_expansion_error) to the wrapper BEFORE the probe, so nothing that could dispatch (a nested gate, a comsub body) executes inside the window; the reachable probe surface is literals/parameter words/globs only.

② Err recovery — complete and exact. The five latches the reachable probe surface can arm (exit_code, command_expansion_failed, evalerror_pending, evalerror_failglob_pending, evalerror_line) are saved before the window and restored in the Err arm before the wrapper fallback. Live: after set -- /no/such/*.zzz &, $? reads the pre-probe value (rc=0, the probe's 1 does not leak), BG_after runs, exactly ONE no match (the wrapper child's) — on 5d51376 the same script prints the diagnostic TWICE, loses BG_after entirely and leaks rc=1, which independently confirms the commit's attribution: master regression from the #809 train (merged as #834), not caused by any #831 change (bisect claim reproduced).

③ Cherry-pick coexistence — zero coupling. The flag gates only the diagnostic print; no ERR-attribution site reads it, and the latch restore lands before any parent-side adjudication, so the silence window can neither create nor suppress an ERR fire. Empirically, set -E + ERR trap + probe hit: GNU and 63f40f3 both fire NO ERR (failglob is an expansion verdict, not a command completion), print exactly one child diagnostic and continue the launch line — byte-identical. The same hunk cherry-picked into fix/809 keeps those semantics (it is additive to the gate, orthogonal to trap_exec.rs). The failglob × collapse battery — ( (… ) ) collapsed, multi-command uncollapsed, f() ( ) flat, plain ( ), collapsed under set -E — is byte-identical with GNU (5 diagnostics, one per shape, rc=1 each, single CX fire).

④ Suites — pass on my runs: regression.rs issue_753 17/17 (case_11 included; 57 filtered), issue720 17/17, issue797 8/8, audit harness 45 cases / same 4 known findings. The full ERR battery (nested-collapse, three-level, non-collapsed controls, brace middle, flat region, multiline LINENO, and-or, set -e ordering, return-in-until/while/plain, lastpipe absorb, G2 top-level) is byte-identical with GNU on 63f40f3.

Two standing notes, unchanged from round 2 and non-blocking: the "goldens 74/74" arithmetic still reads 73+1 on my run (the same pre-existing regression.rs failure on both sides of the baseline); and the round-2 residual exits (ast_exec.rs:357 comsub-parse latch, :1593 IoError+errexit — the latter now naturally foldable into #826's sweep along with this probe area) remain open for the tracker.

No merge from my side; D:/repo/rubash-cr-831 sits at 63f40f3 with no tracked changes; the temp #834 attribution worktree was removed after the check.

…on both sides (patch-id 2571883), CHANGELOG keeps #720 entry + master's cr-816 NIT #806 entry
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