zsh-workers
 help / color / mirror / code / Atom feed
From: "Lawrence Velázquez" <larryv@zsh.org>
To: zsh-workers@zsh.org
Subject: Re: behavior of test true -a \( ! -a \)
Date: Sat, 23 Mar 2024 19:33:18 -0400	[thread overview]
Message-ID: <81df9600-a0c4-4c7b-a4fb-f61106395b96@app.fastmail.com> (raw)
In-Reply-To: <CAH+w=7Y5isnk+tCFWkjhw7e7d9Q7X_zeMqtOHps9SfX3zvsBJg@mail.gmail.com>

On Sat, Mar 23, 2024, at 6:41 PM, Bart Schaefer wrote:
> On Sat, Mar 23, 2024 at 3:20 PM Vincent Lefevre <vincent@vinc17.net> wrote:
>>
>> On 2024-03-23 14:48:36 -0700, Bart Schaefer wrote:
>> > I'd therefore argue that it's actually
>> >
>> > % test \( ! -a \)
>> >
>> > that is wrong
>>
>> POSIX specifies what happens with up to 4 arguments.

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.

> Ok, but
>
> % test \( ! -a \) \)
>
> has five and
>
> % test \( ! -a \) -a true
>
> has six, and in neither case are the "first four" interpreted as you
> would have the "last four" interpreted in
>
> % test true -a \( ! -a \)
>
>> The idea is to
>> interpret the operators in a way so that the expression is meaningful
>
> The only way to do that is to (in effect) start counting arguments
> again when \( is encountered.  That changes the meaning of everything
> with an open paren and more than four words.  At what point do we
> stop?

The current version of POSIX leaves test(1) behavior with more than
4 arguments unspecified but says that:

	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.

I suspect that the Austin Group gave up on the whole thing once
they realized its general intractability.

-- 
vq


  reply	other threads:[~2024-03-23 23:34 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-21 10:07 Vincent Lefevre
2024-03-21 10:28 ` Peter Stephenson
2024-03-21 11:04   ` Vincent Lefevre
2024-03-21 11:29     ` Peter Stephenson
2024-03-21 12:18       ` Vincent Lefevre
2024-03-21 12:25         ` Peter Stephenson
2024-03-21 19:06           ` Bart Schaefer
2024-03-22  5:02             ` Bart Schaefer
2024-03-25 16:38       ` Peter Stephenson
2024-03-25 17:36         ` Bart Schaefer
2024-04-03 13:59           ` Vincent Lefevre
2024-03-21 17:39 ` Bart Schaefer
2024-03-23 21:48   ` Bart Schaefer
2024-03-23 22:20     ` Vincent Lefevre
2024-03-23 22:41       ` Bart Schaefer
2024-03-23 23:33         ` Lawrence Velázquez [this message]
2024-03-24  0:14           ` Bart Schaefer
2024-03-24  2:52             ` Lawrence Velázquez
2024-03-25 10:23         ` Vincent Lefevre
2024-03-25 15:21           ` Bart Schaefer
2024-03-25 17:33             ` Vincent Lefevre
2024-03-25 17:43               ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81df9600-a0c4-4c7b-a4fb-f61106395b96@app.fastmail.com \
    --to=larryv@zsh.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).