Skip to content

fix(interpreter): truncate exit codes to 8-bit range#365

Merged
chaliy merged 1 commit intomainfrom
claude/fix-356-exit-code-truncation-TjcEQ
Feb 27, 2026
Merged

fix(interpreter): truncate exit codes to 8-bit range#365
chaliy merged 1 commit intomainfrom
claude/fix-356-exit-code-truncation-TjcEQ

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 27, 2026

Summary

  • Truncate exit and return codes to 8-bit unsigned range (0-255) via & 0xFF, matching bash behavior
  • Treat quoted empty string ('', "") as "command not found" (exit 127) instead of silently succeeding
  • Enable 9 previously-skipped spec tests in exit-status.test.sh

Test plan

  • All 9 previously-skipped exit-status spec tests now pass
  • exit 256 -> 0, exit 257 -> 1, exit -1 -> 255, exit -2 -> 254
  • return 256 -> 0, return 257 -> 1, return -1 -> 255, return -2 -> 254
  • if ''; then echo TRUE; else echo FALSE; fi -> FALSE
  • Existing tests unaffected (1158 passing, 136 skipped)
  • cargo fmt, cargo clippy clean

Closes #356

Bash truncates exit/return codes to unsigned 8-bit (0-255) via & 0xFF.
Bashkit was passing values >255 and negative values through unchanged.

Changes:
- exit builtin: truncate exit code with & 0xFF
- return builtin: truncate return code with & 0xFF
- Empty quoted command ('', ""): treat as "command not found" (exit 127)
  instead of silently succeeding

Enable 9 previously-skipped spec tests from exit-status.test.sh.

Closes #356

https://claude.ai/code/session_018RLVEEcJBFYsxQKT5wYyNu
@chaliy chaliy merged commit 254a4ad into main Feb 27, 2026
16 checks passed
@chaliy chaliy deleted the claude/fix-356-exit-code-truncation-TjcEQ branch February 27, 2026 06:26
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.

Exit/return codes not truncated to 8-bit range

2 participants