From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25681 invoked by alias); 4 Sep 2013 16:42:11 -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: 31694 Received: (qmail 21633 invoked from network); 4 Sep 2013 16:42:06 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at samsung.com does not designate permitted sender hosts) X-AuditID: cbfec7f4-b7f0a6d000007b1b-ab-522760806981 Date: Wed, 04 Sep 2013 17:31:59 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Builtin test and parsing of conditionals Message-id: <20130904173159.19c55cd1@pwslap01u.europe.root.pri> In-reply-to: <130904091503.ZM28369@torch.brasslantern.com> References: <130904091503.ZM28369@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphluLIzCtJLcpLzFFi42I5/e/4Zd2GBPUgg1kPuS0ONj9kcmD0WHXw A1MAYxSXTUpqTmZZapG+XQJXRmP3RfaCJ+wVcztbWBsY37J2MXJySAiYSKyauJAFwhaTuHBv PVsXIxeHkMBSRonnL54zQzjLmST6G5qYQKpYBFQl5h1dygZiswkYSkzdNJsRxBYREJc4u/Y8 2CRhAVOJrl8LmEFsXgF7iQOf7gJt4+DgFLCS2LFKGCQsJGAp8erRfnYQm19AX+Lq309MEEfY S8y8coYRolVQ4sfke2AjmQW0JDZva2KFsOUlNq95yzyBUWAWkrJZSMpmISlbwMi8ilE0tTS5 oDgpPddQrzgxt7g0L10vOT93EyMkBL/sYFx8zOoQowAHoxIPb4OxepAQa2JZcWXuIUYJDmYl EV45b6AQb0piZVVqUX58UWlOavEhRiYOTqkGxpzH4U8bN/zNvjFbYuWZzhSfpjd9u5YzXLA7 ddQ/TfvPCWGXrzub3I5cFn/ssOV0zAkui/AEs9dCv+1vJ0vcNpJf0rRXbsbm6yWZK8SW/BYI 1zo5q/3ZMyObq2HiN0+XV1a23z13yjdh35do6yblQB/Wm4+b58s/Y/CbsGKyaciM9zmf+Jn+ TVBiKc5INNRiLipOBAD85srLHwIAAA== 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. 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 ! which is how test foo -a bar test foo -o bar are interpreted, which you can see by test foo -a '' # false test foo -o '' # true ... same if you omit the ''. (Outside our control, but I imagine people aren't daft enough to rely on this sort of behaviour in new scripts...?) pws