Re: [BUG] test: -gt: unexpected operator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martijn Dekker <martijn@xxxxxxxx> 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@xxxxxxxx>
Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

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--;
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux