Repository navigation
fix(interpreter): arithmetic errors report and fail instead of giving 0 - #2604
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | a32e2de | Commit Preview URL Branch Preview URL |
Oct 07 2026, 11:23 PM |
chaliy
force-pushed
the
claude/arith-errors
branch
2 times, most recently
from
October 7, 2026 22:59
b1b7714 to
8f2ebed
Compare
Division by zero and a literal outside its base now print bash's message and exit 1; (( )) and let report it themselves and keep the script running. Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
The Python and JS security suites asserted bashkit printed 0 for division and modulo by zero. It now reports like bash and fails, so the expectations move with it. Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
chaliy
force-pushed
the
claude/arith-errors
branch
from
October 7, 2026 23:22
8f2ebed to
a32e2de
Compare
10 tasks done
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.
Requested by Михайло · project thread
What changed
Arithmetic evaluation now has an error channel instead of silently producing
0.$((1/0)),$((1%0)),$((08))and$((2#12))print bash's message and abort the command with status 1.(( ))andletprint the same message with their own((:/let:prefix, fail with status 1, and let the script continue, as bash does.0x1f,010,16#ff,10#08,2#101,64#@.Why
A script computing
$((total/count))withcount=0got0and carried on with a wrong number and a zero exit status. Debian-oracle casesarith-errorsandinteger-overflow-and-base.Before / After
echo $((1/0)); echo after0, thenafter, status 0bash: line 1: 1/0: division by 0 (error token is "0"), status 1,afternot runecho $((08))0bash: line 1: 08: value too great for base (error token is "08")((1/0)); echo $?1with no messagebash: line 1: ((: 1/0: division by 0 ...then1let "y=1/0"; echo $?1with no messagebash: line 1: let: y=1/0: division by 0 ...then1New spec file
arith-errors.test.sh(4 cases), verified against bash 5.2.Risk
Medium-low. Scripts that relied on a silent
0from a division by zero now fail, which is the point. The error carries over&selfin aMutex<ArithError>on the interpreter (it must staySync), locked only on the arithmetic path. An empty right operand, which the operator scan can produce inside a signed literal like-9223372036854775808 / -1, is not treated as a zero divisor, so those paths keep their old values. Error lines readbash: line N:rather than naming the script, since the interpreter does not track the running script's path.Checklist
cargo test -p bashkit --lib,--test integration, bash_comparisoncargo clippy --all-targets -D warnings,cargo fmt --checkhttps://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
Generated by Claude Code