Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: behavior of test true -a \( ! -a \)



On 2024-03-23 14:48:36 -0700, Bart Schaefer wrote:
> I'd therefore argue that it's actually
> 
> % test \( ! -a \)
> 
> that is wrong: It should be complaining of a missing close paren,
> rather than magically reverting to treating "!" as "not" (and also
> "-a" as a plain string).  It's entirely dependent on the count of
> arguments rather than on treating parens as tokens.

POSIX specifies what happens with up to 4 arguments. The idea is to
interpret the operators in a way so that the expression is meaningful
rather than having an incorrect syntax.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - 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)




Messages sorted by: Reverse Date, Date, Thread, Author