diff mbox

[BUG] test: -gt: unexpected operator

Message ID 20150713060635.GA8106@gondor.apana.org.au (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Herbert Xu July 13, 2015, 6:06 a.m. UTC
Martijn Dekker <martijn@inlv.org> wrote:
> I found a bug in dash that affects checking the exit status of '[' or
> 'test' for failure.
> 
> After feeding an illegal number to 'test -t', 'test' will not accept any
> operator (or at least not -gt or -lt) for the next invocation.
> 
> Confirmed in dash 0.5.7, 0.5.8 and current git version.

Thanks for the report.  Does this patch help?

---8<---
Subject: builtin: Reset t_wp_op in testcmd

The global variable t_wp_op needs to be reset every time testcmd
is called or it may cause incorrect parsing of the arguments.

Reported-by: Martijn Dekker <martijn@inlv.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

Martijn Dekker July 13, 2015, 7:17 a.m. UTC | #1
Herbert Xu schreef op 13-07-15 om 08:06:
> Thanks for the report.  Does this patch help?

Yes, it does.

Thanks,

- M.

--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/bltin/test.c b/src/bltin/test.c
index bab9a1f..58c05fe 100644
--- a/src/bltin/test.c
+++ b/src/bltin/test.c
@@ -193,6 +193,8 @@  testcmd(int argc, char **argv)
 		argv[argc] = NULL;
 	}
 
+	t_wp_op = NULL;
+
 recheck:
 	argv++;
 	argc--;