Skip to content

fix(interpreter): set -e ignored contexts reach functions, subshells, $( ) - #2590

Merged
chaliy merged 1 commit into
mainfrom
claude/errexit-contexts
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/errexit-contexts

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

set -e now follows bash's ignored contexts:

  • ! cmd never exits the script.
  • Inside an if/while/until condition, a non-final &&/|| element, or a ! pipeline, errexit stays off in everything that context runs, including function bodies and subshells. This uses a depth counter (errexit_active()), and forked pipeline stages copy it.
  • $( ) clears -e unless shopt -s inherit_errexit is set. With that option the substitution stops at its first failure.

Why

These are roadmap step 1 fidelity gaps. set -e scripts are common in agent output, and bashkit was stricter than bash. check bad && …, if f; then, and x=$(cmd_that_may_fail; echo default) all aborted scripts that bash runs to the end. Debian-oracle cases errexit-exceptions, errexit-subshell-and-cmdsub and errexit-in-function-called-from-and now match bash.

Before / After

Script (set -e) Before After (= bash)
! true; echo ok exits 1 ok
f() { false; echo in; }; if f; then echo y; fi exits in, y
( false; echo sub ) || echo failed failed sub
x=$(false; echo y); echo $x exits 1 y
shopt -s inherit_errexit; x=$(f; echo more) runs on exits 1

Proof: new spec errexit-contexts.test.sh (7 cases, bash-verified), and bash_comparison passes.

Risk

Low-medium. This changes when scripts stop under set -e, toward bash. The existing errexit tests (lib, integration, spec) all pass unchanged.

Checklist

  • Failing spec first
  • cargo test -p bashkit --lib / --test integration / bash_comparison
  • clippy -D warnings, fmt, check-okf
  • knowledge: architecture "set -e contexts", log

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

… $( )

- `! cmd` no longer triggers errexit
- conditions and non-final &&/|| elements ignore errexit inside called
  functions and subshells (depth counter, copied into forked stages)
- command substitution clears -e unless inherit_errexit

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 870253a Commit Preview URL

Branch Preview URL
Oct 07 2026, 07:31 PM

@chaliy
chaliy merged commit 3ac41e5 into main Oct 7, 2026
44 checks passed
@chaliy
chaliy deleted the claude/errexit-contexts branch October 7, 2026 19:50
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