GNU bug report logs - #23222
test: incorrect operator-precedence

Previous Next

Package: coreutils;

Reported by: Mattias Andrée <maandree <at> member.fsf.org>

Date: Tue, 5 Apr 2016 14:56:01 UTC

Severity: normal

Tags: confirmed, fixed

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Mattias Andrée <maandree <at> member.fsf.org>
To: 23222 <at> debbugs.gnu.org
Subject: bug#23222: test: incorrect operator-precedence
Date: Tue, 5 Apr 2016 13:57:16 +0200
[Message part 1 (text/plain, inline)]
Failing test-case #1:

./test -n -a -n

fails and outputs

  ./test: extra argument ‘-n’

Expected behaviour is silent success, as seen in
Bash's implementation.

Explanation: -a has higher precedence than -n.
Therefore the test is equivalent to
./test -n && ./test -n. ./test -n shall succeed
because it is not an operator, but rather a
non-empty string.


Failing test-case #2:

./test ! '' -a ''

shall fail (exit value 1), but in this
implementation it succeeds.

Explanation: ! has higher precedence than -a,
therefore the test shall be equivalent to
./test ! '' && ./test '', not ! ./test '' -a ''.
[Message part 2 (application/pgp-signature, inline)]

This bug report was last modified 6 years and 265 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.