dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Martijn Dekker <martijn@inlv.org>
Cc: dash@vger.kernel.org
Subject: Re: [BUG] test: -gt: unexpected operator
Date: Mon, 13 Jul 2015 14:06:35 +0800	[thread overview]
Message-ID: <20150713060635.GA8106@gondor.apana.org.au> (raw)
In-Reply-To: <55A2F88A.4090908@inlv.org>

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>

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@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2015-07-13  6:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-12 23:30 [BUG] test: -gt: unexpected operator Martijn Dekker
2015-07-13  6:06 ` Herbert Xu [this message]
2015-07-13  7:17   ` Martijn Dekker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150713060635.GA8106@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=dash@vger.kernel.org \
    --cc=martijn@inlv.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).