On 04/05/2016 12:36 PM, Mattias Andrée wrote: >> Sorry, but here, you're wrong. POSIX states: >> >> "4 arguments: >> If $1 is '!', negate the three-argument test of >> $2, $3, and $4." >> >> which means this parses as: >> >> test ! \( '' -a '' \) >> > > XSI-conformant systems shall use the following precedence > rules (highest to lowest), as documented (not quite as clearly) > in the POSIX specifications: > Only for more than four arguments: >4 arguments: The results are unspecified. [OB XSI] [Option Start] On XSI-conformant systems, combinations of primaries and operators shall be evaluated using the precedence and associativity rules described previously. In addition, the string comparison binary primaries '=' and "!=" shall have a higher precedence than any unary primary. [Option End] > The POSIX specification does indeed that that > the number of arguments shall determine the > precedence for 1 to 4 arguments. And the given > rules do conflict with XSI. But if we run > > test \( \( ... \) \) instead of test it seems > only reasonable to use the XSI rules. Yeah, other than the fact that -o and -a are marked obsolescent by POSIX because they are inherently ambiguous, and therefore "The results are unspecified" is a better phrase to rely on than any particular precedence. > I believe that POSIX rule for 4 arguments shall > be disregarded. It is clearly only intended for > other binary operators than logical operators. Sorry, but that's not how POSIX is worded. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org