summaryrefslogtreecommitdiffstats
path: root/bin/test/test.c
diff options
context:
space:
mode:
authorcsgr <csgr@FreeBSD.org>1994-09-11 13:57:31 +0000
committercsgr <csgr@FreeBSD.org>1994-09-11 13:57:31 +0000
commitb819d56caf66a2bbb416cd1a946e286daf646469 (patch)
treeca86369a9fb0914094e68aeca4fc515a587bf285 /bin/test/test.c
parent15c2fa33ec4181b8477c00ae0052d90c04091039 (diff)
downloadFreeBSD-src-b819d56caf66a2bbb416cd1a946e286daf646469.zip
FreeBSD-src-b819d56caf66a2bbb416cd1a946e286daf646469.tar.gz
- handle signs on integers properly,
- make sure error messages for bad integers are moderately sensible - handle test ! "abc" -o "abc" (This should evaluate to true) (and similar cases) ie: and/or operator test added to POSIX special case processing. - more test cases added. Based on: Work done on 1.x's test(1) by Andrew Moore and Adam David.
Diffstat (limited to 'bin/test/test.c')
-rw-r--r--bin/test/test.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/test/test.c b/bin/test/test.c
index b9a8ebf..832257e 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')
OpenPOWER on IntegriCloud