Repository navigation
fix(executor): until-break errexit attribution and -E subshell ERR inheritance (#702) - #719
Merged
Merged
Conversation
…break/continue (#702) An until loop runs its condition with errexit suppressed, leaving the condition's failing status in self.exit_code. The body's first command then runs; break/continue unwound without establishing their own status, so the dispatcher's post-command errexit / ERR-trap gate attributed the condition's failure to that body command. GNU break.def/continue.def return EXECUTION_SUCCESS, so establish that status before unwinding: `until false; do break; done` now reaches the following command and leaves $? = 0, and `until (exit 7); do break; done` no longer leaks 7.
GNU reset_or_restore_signal_handlers keeps the ERR trap in a forked subshell child when error_trace_mode (-E) is set, exactly as it keeps DEBUG/RETURN under functrace (-T). reset_for_subshell unconditionally recorded ERR as reset, so the inherited trap never fired inside a `( )` body even with -E. Add a subshell-child variant that honors errtrace and use it from the two true subshell entry points; the command-substitution, pipeline-element and read copy paths keep the unconditional reset they model separately.
GNU bash 5.3.0 byte-verified expectations for the until/break attribution (while/for unaffected, leading no-op unaffected, condition status non-leaking, ERR trap silent) and for -E propagation into `( )` subshells (plain subshell, function-in-subshell, comsub-wrapped subshell, and the no-errtrace control).
This was referenced Oct 17, 2026
This was referenced Oct 30, 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.
Fixes the two deterministic
errexit/ trap-inheritance divergences from GNU bash reported in #702.R4.1 —
set -emisfires in anuntilloop whose body starts withbreak/continueAn
untilloop evaluates its condition with errexit suppressed and leaves the condition's failing status in the shell status. The body's first command then runs;break/continueunwound without establishing their own status, so the dispatcher's post-command errexit / ERR-trap gate attributed the condition's status to that body command:GNU
break.def/continue.defreturnEXECUTION_SUCCESSfor an in-range count; the fix establishes that status inexecute_loop_controlbefore unwinding, so the attribution is correct for every loop form and every position (directly or as the first command of a group).while true; do break; done,for i in 1; do break; doneanduntil false; do :; break; doneare unchanged.R4.2 —
set -Enot inherited by( )subshellsGNU
reset_or_restore_signal_handlerskeeps the ERR trap in a forked subshell child whenerror_trace_mode(set -E) is set, exactly as it keepsDEBUG/RETURNunderfunctrace(set -T). rubash'sreset_for_subshellunconditionally recordedERRas reset, so the inherited trap never fired inside a( )body even with-E:A subshell-child variant of the reset honors
errtraceand is used from the two true subshell entry points (( )andf() ( )bodies). The command-substitution, pipeline-element andreadcopy paths keep the unconditional reset they model separately. Without-Ethe behavior is unchanged (trap 'echo ERR' ERR; ( false )still fires once), and a subshell still lists the inherited trap (( trap -p ERR )).Tests
New
tests/issue702_errexit_until_break_regressions.rspins all of the above against byte-verified GNU bash 5.3.0 output, including the unaffectedwhile/forforms, the leading-:control, condition-status non-leak, ERR-trap silence, and the no-errtrace control.Focused suites run green:
issue702_*,issue531,issue520,issue343_345,issue546,issue524,issue439,issue395,issue507,issue70,issue_s6,issue661,issue485,issue302_304,issue505,issue543,issue589,issue294,issue345; lib filterstrap/loop;cargo fmt --checkclean.Known adjacent quirks (left alone, pre-existing and out of #702's scope)
( (false) )with-E: GNU 2 ERR fires, this branch 3 (a nested subshell as the first body command over-fires; GNU suppresses the middle-level fire).f() ( false ); fwith-E: GNU 3, this branch 2 (the function-with-subshell-body call is missing one of GNU's two level-0 fires).cat <(false)with-E(process substitution) still differs; the process-substitution copy path was not touched.