🤔 Background
The standalone assert subcommand does not check that it received enough arguments before indexing the argument array.
local last_index=$((args_count - 1))
local last_arg="${args[$last_index]}"
With no arguments after the assertion name, args_count is 0, so last_index is -1. Bash 3.x has no negative array subscripts, so the expansion fails — and the run continues and exits 0:
$ ./bashunit assert equals
./src/main.sh: line 1182: args: bad array subscript
$ echo $?
0
A malformed standalone assertion reports success. docs/standalone.md presents this subcommand for integration and end-to-end checks, so a mistyped invocation in a deploy script passes silently.
Working cases, for contrast
The rest of the subcommand handles errors well — this is the one gap:
| Invocation |
Result |
assert equals foo foo |
exit 0 |
assert equals foo bar |
exit 1, ✗ Failed: assert equals |
assert no_such_assertion foo foo |
exit 127, Function no_such_assertion does not exist. |
assert equals |
exit 0, bad array subscript |
Suggested fix
Reject an argument count below what the assertion needs with a clear message and a non-zero exit, in the same style as the existing "Function ... does not exist." path. Note the negative-subscript expansion is also a Bash 3.0 compatibility violation per .claude/rules/bash-style.md.
🤔 Background
The standalone
assertsubcommand does not check that it received enough arguments before indexing the argument array.With no arguments after the assertion name,
args_countis0, solast_indexis-1. Bash 3.x has no negative array subscripts, so the expansion fails — and the run continues and exits0:A malformed standalone assertion reports success.
docs/standalone.mdpresents this subcommand for integration and end-to-end checks, so a mistyped invocation in a deploy script passes silently.Working cases, for contrast
The rest of the subcommand handles errors well — this is the one gap:
assert equals foo fooassert equals foo bar✗ Failed: assert equalsassert no_such_assertion foo fooFunction no_such_assertion does not exist.assert equalsbad array subscriptSuggested fix
Reject an argument count below what the assertion needs with a clear message and a non-zero exit, in the same style as the existing "Function ... does not exist." path. Note the negative-subscript expansion is also a Bash 3.0 compatibility violation per
.claude/rules/bash-style.md.