test incorrectly rejecting valid expression with confusing ! placement
Harald van Dijk <harald <at> gigawatt.nl>
2013-08-24 14:01:17 GMT
Now that Herbert fixed the reported crash in test (in a far simpler
manner than I had suggested, which I like), I did some more testing, and
came across one case that does not currently work, and did not work in
the past, but is perfectly valid:
$ src/dash -c 'test ! ! = !'
src/dash: 1: test: =: unexpected operator
POSIX requires special behaviour for four-argument tests:
If $1 is '!', negate the three-argument test of $2, $3, and $4.
so this is supposed to evaluate as the negation of test ! = !. That test
does work properly in dash.
There are also some cases where test gives incorrect results when
combining ! with -o, but ( ), -a and -o have been obsoleted in favour of
the built-in shell operators ( ), && and ||, so I am not sure if that is
worth fixing. Details anyway:
$ src/dash -c 'test ! -o !'
src/dash: 1: test: -o: unexpected operator
This is covered by the special rule for three arguments, where the
second argument is a binary operator. -o is a boolean binary operator,
but a binary operator nonetheless, so this should test whether the two !