cmd_test: check for binary operators before unary
authorStephen Warren <swarren@nvidia.com>
Mon, 3 Feb 2014 20:21:03 +0000 (13:21 -0700)
committerTom Rini <trini@ti.com>
Wed, 19 Feb 2014 14:47:33 +0000 (09:47 -0500)
commit4c80f29edd33cc613d01c5e93dde380b98d3c20c
treed8f9f205d32d1d02d446ad97813aaeb613273d10
parent490ba833d5a7804ca81b13b3f8f2c37aadc40009
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>
common/cmd_test.c