diff --git a/bin/test/TEST.csh b/bin/test/TEST.csh index e5b9652bc5d..e36ec846dcd 100644 --- a/bin/test/TEST.csh +++ b/bin/test/TEST.csh @@ -135,3 +135,17 @@ echo 't 700 -le 1000 -a -n "1" -a "20" = "20"' t 700 -le 1000 -a -n "1" -a "20" = "20" echo 't ! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)' t ! \( 700 -le 1000 -a -n "1" -a "20" = "20" \) + +echo 't -5 -eq 5' +t -5 -eq 5 + + +echo 't foo -a ""' +t foo -a "" +echo 't "" -a foo' +t "" -a foo +echo 't "" -a ""' +t "" -a "" +echo 't "" -o ""' +t "" -o "" + diff --git a/bin/test/operators.c b/bin/test/operators.c index 335223baa98..21f653fda19 100644 --- a/bin/test/operators.c +++ b/bin/test/operators.c @@ -81,6 +81,16 @@ const char *const binary_op[] = { NULL }; +const char *const andor_op[] = { + "-o", + "|", + "-a", + "&", + NULL +}; + + + const char op_priority[] = { 3, 12, diff --git a/bin/test/operators.h b/bin/test/operators.h index f8746dffd35..74a5a95acf9 100644 --- a/bin/test/operators.h +++ b/bin/test/operators.h @@ -73,5 +73,6 @@ extern const char *const unary_op[]; extern const char *const binary_op[]; +extern const char *const andor_op[]; extern const char op_priority[]; extern const char op_argflag[]; diff --git a/bin/test/test.c b/bin/test/test.c index b9a8ebf0e49..832257e2932 100644 --- a/bin/test/test.c +++ b/bin/test/test.c @@ -161,7 +161,7 @@ main(argc, argv) } break; case 4: /* % test ! arg1 op arg2 */ - if (IS_BANG(argv[1])) { + if (IS_BANG(argv[1]) && lookup_op(argv[3], andor_op) < 0 ) { ret_val = posix_binary_op(&argv[2]); if (ret_val >= 0) return (!ret_val); @@ -528,7 +528,8 @@ get_int(v, lp) char *ep; for (; *v && isspace(*v); ++v); - if (isdigit(*v)) { + + if (isdigit(*v) || ((*v == '-' || *v == '+') && isdigit(*(v+1)))) { errno = 0; val = strtol(v, &ep, 10); if (*ep != '\0')