Skip to content

fix(builtins): usage errors fail the command, not the script - #2560

Merged
chaliy merged 2 commits into
mainfrom
claude/builtin-errors-nonfatal
Oct 7, 2026
Merged

chaliy merged 2 commits into
mainfrom
claude/builtin-errors-nonfatal

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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

What changed

A usage error in one of bashkit's own builtins now fails only that command. It exits 2 with the message on stderr, and the script keeps going, as in bash. Affected cases:

  • grep -E '(' and grep -P with a bad pattern
  • rg with a bad regex
  • an awk syntax error
  • grep with no pattern, or grep -f missing

set -e still stops on them.

Err returned by a custom builtin (BashBuilder::builtin, BuiltinRegistry, CommandResolver) still aborts exec(), which is the existing public contract. Limits, cancellation and I/O errors still abort for every builtin.

Why

Before, a single bad regex in an agent's script killed the whole run and dropped the output of every command after it. This was found while probing awk for the gap report.

Before

$ bashkit -c 'awk "BEGIN{,}"; echo after=$?'
Error: execution error: awk: unexpected character: ,

After

awk: unexpected character: ,
after=2

The new builtin-usage-errors.test.sh (6 cases) matches bash 5.2 with GNU grep and mawk; the rg case is bashkit-only.

Risk

Medium-low. The rule lives in the builtin dispatcher and applies only when the builtin being run is the bundled one, checked by pointer identity and not overridden by name. The trace-isolation test now uses a custom fatal builtin for its failure path, since grep no longer aborts. Error text is capped at 1 KB (TM-INF-022).

Checklist

  • Failing spec first, verified against bash
  • cargo test -p bashkit --lib --tests, clippy, fmt
  • knowledge/foundations/builtins.md, docs/custom_builtins.md, knowledge/log.md

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

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 15afca9 Commit Preview URL

Branch Preview URL
Oct 07 2026, 01:07 PM

@chaliy
chaliy force-pushed the claude/builtin-errors-nonfatal branch from 27bca4b to a81ac68 Compare October 7, 2026 12:49
chaliy added 2 commits October 7, 2026 13:06
grep -E '(' or an awk syntax error returned Err from the builtin, which
aborted the whole exec. Bundled builtins' Execution/Regex errors now
become exit 2 with the message on stderr, as in bash. Err from custom
builtins (builder, registry, resolver) still aborts.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy
chaliy force-pushed the claude/builtin-errors-nonfatal branch from e3b9f0d to 15afca9 Compare October 7, 2026 13:06
@chaliy
chaliy merged commit 5a172f4 into main Oct 7, 2026
47 checks passed
@chaliy
chaliy deleted the claude/builtin-errors-nonfatal branch October 7, 2026 13:37
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