]> git.ipfire.org Git - thirdparty/u-boot.git/commit
cmd: test: fix handling of single-argument form of test
authorRasmus Villemoes <ravi@prevas.dk>
Thu, 12 Mar 2026 10:01:06 +0000 (11:01 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 25 Mar 2026 20:37:55 +0000 (14:37 -0600)
commit8b0619579b2282050e7fb0d92fbc645b79d18bae
tree9f2fd0ce8625dc8a5709f423420ec232c9a9f51b
parent6f9cc3310a764aaae4478b5a8a0c0cae3b2be4a1
cmd: test: fix handling of single-argument form of test

POSIX states that

  0 arguments:
      Exit false (1).
  1 argument:
      Exit true (0) if $1 is not null; otherwise, exit false.

and at least bash and busybox sh behave that way.

The current 'argc < 3' does the right thing for a non-existing or
empty argv[1], but not for a non-empty argv[1]. Fix that and add
corresponding test cases.

Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
Tested-by: Anshul Dalal <anshuld@ti.com>
cmd/test.c
test/hush/if.c