From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 594 invoked by alias); 4 Sep 2013 17:39:30 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 31695 Received: (qmail 14781 invoked from network); 4 Sep 2013 17:39:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130904103940.ZM28454@torch.brasslantern.com> Date: Wed, 04 Sep 2013 10:39:40 -0700 In-reply-to: <20130904173159.19c55cd1@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: Builtin test and parsing of conditionals" (Sep 4, 5:31pm) References: <130904091503.ZM28369@torch.brasslantern.com> <20130904173159.19c55cd1@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Builtin test and parsing of conditionals MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 4, 5:31pm, Peter Stephenson wrote: } Subject: Re: Builtin test and parsing of conditionals } } On Wed, 04 Sep 2013 09:15:03 -0700 } Bart Schaefer wrote: } > According to some discussion on the austin-group (POSIX) mailing list, } > the following: } > } > test ! -a ! } > test ! -o ! } > test ! = ! } > } > should all be parsed as comparing the string "!" to the string "!", but } > zsh gets this right only in the last case. } } I don't understand that. -a means "and" and -o means "or", unless } they're being interpreted as strings, but I don't see how that could be } if ! is supposed to be interpreted as a string. Sorry, perhaps I should have been clearer: "! -a !" means to compare the truth value "!" to the truth value of "!". But "truth value" in "test" is the same as "non-empty string" (true) and "empty string" (false) [not 0 or 1 as numeric values], so the -a operator is still comparing two strings. The point being that "!" should be parsed as a string, not as a negation operator, in the three-argument case. } So where does the } implicit comparison come from? If -a were taken as high precedence you } might read it as } } test -n ! -a n ! } test -n ! -a n ! Presuming you mean -a -n there, this is exactly how the austin-group thread claims it should be interpreted, and is reportedly how ksh and bash and GNU /usr/bin/test all interpret it. } (Outside our control, but I imagine people aren't daft enough to rely on } this sort of behaviour in new scripts...?) I would hope so, but ...