cmd_test: check for binary operators before unary
authorStephen Warren <swarren@nvidia.com>
Mon, 3 Feb 2014 20:21:03 +0000 (13:21 -0700)
committerjino.cho <jino.cho@samsung.com>
Tue, 28 Feb 2017 10:11:29 +0000 (19:11 +0900)
commit84aa0d91917faced19a6121f0b0c03387ba4bdf1
treedacc5153f9ba635d1368a7416b8df346145cd423
parenta75c04813d669e2fd65e47cdc6e948ae7abe13e2
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