summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2014-02-03 13:21:03 -0700
committerTom Rini <trini@ti.com>2014-02-19 09:47:33 -0500
commit4c80f29edd33cc613d01c5e93dde380b98d3c20c (patch)
treed8f9f205d32d1d02d446ad97813aaeb613273d10
parent490ba833d5a7804ca81b13b3f8f2c37aadc40009 (diff)
downloadtalos-obmc-uboot-4c80f29edd33cc613d01c5e93dde380b98d3c20c.tar.gz
talos-obmc-uboot-4c80f29edd33cc613d01c5e93dde380b98d3c20c.zip
cmd_test: check for binary operators before unary
This better mirrors the behaviour of bash, for example: $ if test -z = -z; then echo yes; else echo no; fi yes This is parsed as a string comparison of "-z" and "-z", since the check for the binary "=" operator occurs first. Without this change, the command would be parsed as a -z test of "-", followed by a syntax error; a trailing -z without and operand. This is a behavioural change, but I believe any commands affected were previously invalid or bizarely formed. Signed-off-by: Stephen Warren <swarren@nvidia.com>
-rw-r--r--common/cmd_test.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/common/cmd_test.c b/common/cmd_test.c
index 69b1b4cee6..e65dd53187 100644
--- a/common/cmd_test.c
+++ b/common/cmd_test.c
@@ -39,10 +39,6 @@ const struct {
int op;
int adv;
} op_adv[] = {
- {0, "-o", OP_OR, 1},
- {0, "-a", OP_AND, 1},
- {0, "-z", OP_STR_EMPTY, 2},
- {0, "-n", OP_STR_NEMPTY, 2},
{1, "=", OP_STR_EQ, 3},
{1, "!=", OP_STR_NEQ, 3},
{1, "<", OP_STR_LT, 3},
@@ -53,6 +49,10 @@ const struct {
{1, "-le", OP_INT_LE, 3},
{1, "-gt", OP_INT_GT, 3},
{1, "-ge", OP_INT_GE, 3},
+ {0, "-o", OP_OR, 1},
+ {0, "-a", OP_AND, 1},
+ {0, "-z", OP_STR_EMPTY, 2},
+ {0, "-n", OP_STR_NEMPTY, 2},
};
static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
OpenPOWER on IntegriCloud