dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martijn Dekker <martijn@inlv.org>
To: dash@vger.kernel.org
Subject: [BUG] test: -gt: unexpected operator
Date: Mon, 13 Jul 2015 01:30:18 +0200	[thread overview]
Message-ID: <55A2F88A.4090908@inlv.org> (raw)

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.

$ [ -t 12323454234578326584376438 ]
src/dash: 7: [: Illegal number: 12323454234578326584376438
$ [ "$?" -gt 1 ] && echo error
src/dash: 8: [: -gt: unexpected operator
$ [ "$?" -gt 1 ] && echo error
error
$ test -t 12323454234578326584376438
src/dash: 10: test: Illegal number: 12323454234578326584376438
$ test "$?" -gt 1 && echo error
src/dash: 11: test: -gt: unexpected operator
$ test "$?" -gt 1 && echo error
error
$ test -t 12323454234578326584376438
src/dash: 13: test: Illegal number: 12323454234578326584376438
$ test 2 -gt 1
src/dash: 14: test: -gt: unexpected operator
$ test 2 -gt 1
$ test -t 12323454234578326584376438
src/dash: 16: test: Illegal number: 12323454234578326584376438
$ test 2 -lt 1
src/dash: 17: test: -lt: unexpected operator
$ test 2 -lt 1
$

Thanks,

- Martijn

             reply	other threads:[~2015-07-12 23:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-12 23:30 Martijn Dekker [this message]
2015-07-13  6:06 ` [BUG] test: -gt: unexpected operator Herbert Xu
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=55A2F88A.4090908@inlv.org \
    --to=martijn@inlv.org \
    --cc=dash@vger.kernel.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).