aboutsummaryrefslogtreecommitdiff
path: root/coreutils/test.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-07-17 00:59:26 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-07-17 00:59:26 +0200
commitd23f64eba79a702c36d8d8cec23b49c320897138 (patch)
treeb998ad8732c6ceec17dbaf59fe7bd0539b3f2f68 /coreutils/test.c
parentfff73641e473763ba47c84f5c04eb0fc0da6d64b (diff)
downloadbusybox-d23f64eba79a702c36d8d8cec23b49c320897138.tar.gz
test: fix "test !" and "test abc -a !". closes bug 465
function old new delta nexpr 826 840 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/test.c')
-rw-r--r--coreutils/test.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index 73048d311..c430f2210 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -627,7 +627,14 @@ static number_t nexpr(enum token n)
nest_msg(">nexpr(%s)\n", TOKSTR[n]);
if (n == UNOT) {
- res = !nexpr(check_operator(*++args));
+ n = check_operator(*++args);
+ if (n == EOI) {
+ /* special case: [ ! ], [ a -a ! ] are valid */
+ /* IOW, "! ARG" may miss ARG */
+ unnest_msg("<nexpr:1 (!EOI)\n");
+ return 1;
+ }
+ res = !nexpr(n);
unnest_msg("<nexpr:%lld\n", res);
return res;
}
@@ -798,7 +805,7 @@ int test_main(int argc, char **argv)
check_operator(argv[1]);
if (last_operator->op_type == BINOP) {
/* "test [!] arg1 <binary_op> arg2" */
- args = &argv[0];
+ args = argv;
res = (binop() == 0);
goto ret;
}
@@ -811,7 +818,7 @@ int test_main(int argc, char **argv)
argv--;
}
#endif
- args = &argv[0];
+ args = argv;
res = !oexpr(check_operator(*args));
if (*args != NULL && *++args != NULL) {