Subject: [BUG] 'test' returns 1 (not >1) on error [was: test is not posix]
From: Martijn Dekker <[email-masked]>
To: [email-masked]
Cc: Peter Stephenson <[email-masked]>
Date: Thu, 21 Jan 2016 14:06:38 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Peter Stephenson schreef op 21-01-16 om 13:41:
> Yes, we now have tests for the following cases.  It's trivial to add more
> if you can think of any that might be problematic.

Something I also noticed back in May, and which I'm now reminded of, is
that test/[ returns status 1, and not 2 or higher, if an error occurs.

$ [ x = a b ]
[: too many arguments
$ echo $?
1
$ [ 1 -eq ]
zsh: parse error: condition expected: 1
$ echo $?
1

This makes it impossible to test for the failure of test/[ using the
exit status.

POSIX says the status should be 2 or higher on error:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128_14

Thanks,

- Martijn