https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
says for >4 arguments with XSI:

  In addition, the string comparison binary primaries '=' and "!="
  shall have a higher precedence than any unary primary.

(note the "shall"). So, what about the following command?

  test ! = -o ! ''

Should the '=' be regarded as having a higher precedence than '!',
in which case, this is an error? Or should one regard this like the
following command to avoid an error?

  test ! = || test ! ''

But POSIX does not say "unless this gives an error", so I would regard
the former as being the correct behavior; this is what zsh 5.9 does:

qaa% test ! = -o ! '' ; echo $?
test: too many arguments
2

But most implementations output 0.

-- 
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

  • behavior of test ! = ... Vincent Lefevre via austin-group-l at The Open Group

Reply via email to