Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[BUG] 'test' returns 1 (not >1) on error [was: test is not posix]
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author