aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-04-07 16:54:09 -0500
committerRob Landley <rob@landley.net>2020-04-07 16:54:09 -0500
commit75240c713b7aa0a769852d643589c90719f2e31b (patch)
tree2fcb2d709a41d45a6d860c76555c74f38196827f /toys
parent017a59e211c7430631329fe8a40427accca9b92d (diff)
downloadtoybox-75240c713b7aa0a769852d643589c90719f2e31b.tar.gz
Use optc to detect end of arguments, because [ removes ] but doesn't zero it.
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/test.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/toys/posix/test.c b/toys/posix/test.c
index 87a866a7..cf6e1f50 100644
--- a/toys/posix/test.c
+++ b/toys/posix/test.c
@@ -102,7 +102,7 @@ void test_main(void)
if (toys.optc) for (pos = paren = pstack = 0; ; pos++) {
int len = toys.optc-pos;
- if (!toys.optargs[pos]) perror_exit("need arg @%d", pos);
+ if (!len) perror_exit("need arg @%d", pos);
// Evaluate next test
result = do_test(toys.optargs+pos, &len);
@@ -132,14 +132,14 @@ void test_main(void)
else if (pstack&AND) result = 0;
// Do it again for every )
- if (!paren || !s || strcmp(")", s)) break;
+ if (!paren || pos==toys.optc || strcmp(")", s)) break;
paren--;
pstack >>= 3;
s = toys.optargs[++pos];
}
// Out of arguments?
- if (!s) {
+ if (pos==toys.optc) {
if (paren) perror_exit("need )");
break;
}