Description
Bash truncates exit and return codes to an unsigned 8-bit range (0-255). Bashkit does not perform this truncation, passing through values > 255 or negative values directly.
Scope
exit 256 should produce exit code 0 (256 mod 256)
exit 257 should produce exit code 1
exit -1 should produce exit code 255 (two's complement wrap)
exit -2 should produce exit code 254
- Same behavior for
return in functions
'' as a command should fail (exit code 127), not succeed
Repro
f() { return 256; }; f; echo $?
# bashkit outputs: 256 (wrong)
# expected: 0
f() { return -1; }; f; echo $?
# bashkit outputs: -1 (wrong)
# expected: 255
if ''; then echo TRUE; else echo FALSE; fi
# bashkit outputs: TRUE (wrong)
# expected: FALSE
Test coverage
9 skipped tests in crates/bashkit/tests/spec_cases/bash/exit-status.test.sh (PR #351).
Oils reference: https://github.com/oilshell/oil/blob/master/spec/exit-status.test.sh
Description
Bash truncates exit and return codes to an unsigned 8-bit range (0-255). Bashkit does not perform this truncation, passing through values > 255 or negative values directly.
Scope
exit 256should produce exit code 0 (256 mod 256)exit 257should produce exit code 1exit -1should produce exit code 255 (two's complement wrap)exit -2should produce exit code 254returnin functions''as a command should fail (exit code 127), not succeedRepro
Test coverage
9 skipped tests in
crates/bashkit/tests/spec_cases/bash/exit-status.test.sh(PR #351).Oils reference: https://github.com/oilshell/oil/blob/master/spec/exit-status.test.sh