cmd_test: evaluate to false without any arguments
authorStephen Warren <swarren@nvidia.com>
Mon, 3 Feb 2014 20:21:05 +0000 (13:21 -0700)
committerjino.cho <jino.cho@samsung.com>
Tue, 28 Feb 2017 10:12:15 +0000 (19:12 +0900)
This emulates bash:
$ if test; then echo yes; else echo no; fi
no

Currently, the code sets expr = -1 in this case, which gets mapped to
0 (true) at the end of do_test() by the logical -> shell exit code
conversion.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
common/cmd_test.c

index 0149d7edfa46133c3967d997a061b87c915fc75e..f1b15c9a734de1c74f9b99392cec8f43fea8ea52 100644 (file)
@@ -93,7 +93,7 @@ static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
        left = argc - 1;
        ap = argv + 1;
-       expr = -1;
+       expr = 0;
        last_unop = OP_INVALID;
        last_binop = OP_INVALID;
        last_expr = -1;