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

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



On Sat, Mar 23, 2024, at 8:14 PM, Bart Schaefer wrote:
> On Sat, Mar 23, 2024 at 4:33 PM Lawrence Velázquez <larryv@xxxxxxx> wrote:
>>
>> The next version of POSIX will only specify what happens with four
>> arguments if the very first one is "!".  The "-a" and "-o" primaries
>> and the "(" and ")" operators have been removed.
>
> So, no "and"/"or" at all, and no grouping?  Or are they just demoted
> from "primary" and "operator" in some way?

The former -- everything marked "OB" in the current "test" spec [1]
has been completely excised from the upcoming one (although shells
can retain them as extensions to the standard, to avoid breaking
scripts).  The current "Application Usage" section [2] already
recommends that portable scripts stick to simpler "test" commands
connected with general shell syntax, like so:

	test -f "$foo" || { test ! "$bar" && test -d "$baz"; }

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
[2]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128_16

-- 
vq




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