Skip to content

fix(cli): reject a standalone assertion with no arguments#878

Merged
Chemaclass merged 1 commit into
mainfrom
fix/assert-missing-args
Jul 25, 2026
Merged

fix(cli): reject a standalone assertion with no arguments#878
Chemaclass merged 1 commit into
mainfrom
fix/assert-missing-args

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #877

exec_assert computed last_index as args_count - 1 without checking the count.
With no arguments that is -1, and Bash 3.x has no negative array subscripts, so the
expansion failed with a raw bad array subscript — and the run still exited 0.

docs/standalone.md presents this subcommand for integration and end-to-end checks, so
a mistyped invocation in a deploy script reported success.

💡 Changes

  • Reject an assertion invoked with no arguments, naming it in the message, and exit non-zero
  • Removes a Bash 3.0 compatibility violation (negative array subscript) flagged by .claude/rules/bash-style.md
  • Add acceptance coverage for both crash shapes plus a guard that a single-argument assertion (assert empty "") still succeeds

exec_assert computed last_index as args_count - 1 without checking the
count. With no arguments that is -1, and Bash 3.x has no negative array
subscripts, so the expansion failed with a raw 'bad array subscript' and
the run still exited 0:

  $ ./bashunit assert equals
  ./src/main.sh: line 1131: args: bad array subscript
  $ echo $?
  0

docs/standalone.md presents this subcommand for integration checks, so a
mistyped invocation in a deploy script reported success. It now errors
naming the assertion and exits non-zero.

Closes #877
@Chemaclass Chemaclass added the bug Something isn't working label Jul 25, 2026
@Chemaclass Chemaclass self-assigned this Jul 25, 2026
@Chemaclass
Chemaclass merged commit 43a5300 into main Jul 25, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the fix/assert-missing-args branch July 25, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant