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

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



On 2024-03-25 08:21:53 -0700, Bart Schaefer wrote:
> On Mon, Mar 25, 2024 at 3:24 AM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> > I meant that
> >
> >   test \( ! -a \)
> >
> > has four, thus fully specified and not wrong.
> 
> And I meant (in the follow-up, being unaware of the exact spec at
> first) that I think it was wrong to specify it that way in the first
> place.

Well, "test" with its ambiguities between strings and operators should
have never existed in the first place.

> I suspect that we're re-hashing an argument that's already been had on
> austin-group and led to these constructs being first declared obsolete
> and soon dropped.

Dropped from the standard, but not from existing scripts.

> > Concerning
> >
> >   test true -a \( ! -a \)
> >
> > I would say that if you decide that the first "-a" is an "and",
> > then after this "-a", there remain exactly 4 arguments, so that
> > for *consistency*, I think that the remaining 4 arguments should
> > be interpreted exactly as in
> >
> >   test \( ! -a \)
> 
> So what about
>   test true -a \( ! -a \) \)
> ??

With zsh, this is consistent:

cventin% test \( ! -a \) \) ; echo $?
0
cventin% test true -a \( ! -a \) \) ; echo $?
0

The other implementations see consistent too.

-- 
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