Subject: test: incorrect operator-precedence

From: Mattias Andrée <[email-masked]>
Date: Tue, 5 Apr 2016 13:57:16 +0200

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 ''.