Re: test incorrectly rejecting valid expression with confusing ! placement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 03, 2013 at 08:38:16PM -0600, Eric Blake wrote:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
> states that there are only two operators "!" and "()", and specifically
> mentions that -a and -o are binary primaries:

Well, a primary is usually something that cannot be reduced
further when discussing syntax.  As both -a and -o take expressions
on either side, it is highly unusual to designate them as primaries
instead of operators.

Also, in the rationale it clearly states that -a/-o are operators
and not primaries.

In any case, dash does not claim XSI conformance, so we're at
liberty to choose the most suitable implementation of an existing
feature that we inherited from BSD.
 
> "test ! -o !" is a three-argument test, where $2 (-o) is a binary
> primary, so it is the binary test of $1 and $3, and the end result is an
> exit status of 0.  Bash and ksh get it right, dash fails.

Both zsh and posh do it like dash:

$ zsh -c 'test ! -o !'; echo $?
zsh:test:1: too many arguments
1
$ zsh -c 'test ! = !'; echo $?
0
$

Cheers,
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux