docs(assert): correct the assert_true guidance — arguments need an eval prefix - #993
Merged
Conversation
…al prefix #991 documented `assert_true "test -d /tmp"` as the way to test a condition. That does not work, and I should have run it before writing it down. bashunit::run_command_or_eval invokes its argument as a *single command word*. It never splits on whitespace, so `test -d /tmp` is looked up as a command whose name is literally "test -d /tmp", which does not exist. The assertion fails with `unknown command: test -d /tmp` -- correct behaviour, wrong advice. The forms that work, each verified rather than assumed: assert_true "my_function" # bare name assert_true "eval test -d /tmp" # arguments need eval assert_true "eval [ -d /tmp ]" # brackets work too, with eval The `eval ` prefix is already a supported branch in run_command_or_eval; it was simply never documented, so the single-word restriction looked like a bug rather than a calling convention. Snapshot regenerated. The underlying question -- whether requiring `eval` is the right interface, given how surprising `assert_true "grep -q foo file"` failing is -- is filed separately.
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.
🤔 Background
#991 documented
assert_true "test -d /tmp"as the way to test a condition. That doesn't work, and I should have run it before writing it down.bashunit::run_command_or_evalinvokes its argument as a single command word. It never splits on whitespace, sotest -d /tmpis looked up as a command literally namedtest -d /tmp. The assertion fails withunknown command: test -d /tmp— correct behaviour, wrong advice.💡 The forms that actually work
Each verified by running it, not assumed:
The
evalprefix is already a supported branch inrun_command_or_eval— it was simply never documented, which made the single-word restriction look like a bug rather than a calling convention.📋 Follow-up
Whether requiring
evalis the right interface at all — given how surprising it is thatassert_true "grep -q foo file"fails — is worth deciding separately, and I'll file it.✅ Verification
Doc snapshot regenerated.
make sa·make lint· full suite and acceptance green.