From 75240c713b7aa0a769852d643589c90719f2e31b Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 7 Apr 2020 16:54:09 -0500 Subject: Use optc to detect end of arguments, because [ removes ] but doesn't zero it. --- toys/posix/test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'toys/posix/test.c') 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; } -- cgit v1.2.3