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;
}
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;
}
argv--;
}
#endif
- args = &argv[0];
+ args = argv;
res = !oexpr(check_operator(*args));
if (*args != NULL && *++args != NULL) {
"1\n" \
"" ""
+testing "test !: should be true (0)" \
+ "busybox test !; echo \$?" \
+ "0\n" \
+ "" ""
+
testing "test a: should be true (0)" \
"busybox test a; echo \$?" \
"0\n" \
"1\n" \
"" ""
+testing "test a -a !: should be true (0)" \
+ "busybox test a -a !; echo \$?" \
+ "0\n" \
+ "" ""
+
testing "test -f = a -o b: should be true (0)" \
"busybox test -f = a -o b; echo \$?" \
"0\n" \