From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7810 invoked by alias); 28 Feb 2017 12:02:20 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22515 Received: (qmail 8346 invoked from network); 28 Feb 2017 12:02:20 -0000 X-Qmail-Scanner-Diagnostics: from mailout2.w1.samsung.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(210.118.77.12):SA:0(-5.0/5.0):. Processed in 4.83735 secs); 28 Feb 2017 12:02:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at samsung.com does not designate permitted sender hosts) X-AuditID: cbfec7f4-f79716d000006f65-7f-58b564637fdc Date: Tue, 28 Feb 2017 11:51:58 +0000 From: Peter Stephenson To: Zsh Users' List Subject: Re: [BUG] Condition in [[ doesn't fire, with "if" it fires Message-id: <20170228115158.727f67ff@pwslap01u.europe.root.pri> In-reply-to: <1488281256.2881475.895357184.6106CE5C@webmail.messagingengine.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+NgFnrLIsWRmVeSWpSXmKPExsWy7djPc7rJKVsjDNquSVjsOLmS0YHRY9XB D0wB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77VTQP0cHCwCqhJv+oJARrEJGEpM3TSb EcQWEVCXWHG9nQnEFhZwlph+5jxYnFfAXuL+lhtgNqdAgMTdeV/BzhASeMko0b+iHsTmF9CX uPr3ExPEefYSM6+cgeoVlPgx+R4LiM0soCWxeVsTK4QtL7F5zVtmiDnqEjfu7mafwCg8C0nL LCQts5C0LGBkXsUoklpanJueW2ykV5yYW1yal66XnJ+7iREYRduO/dyyg7HrXfAhRgEORiUe 3gcGWyKEWBPLiitzDzFKcDArifB2hG+NEOJNSaysSi3Kjy8qzUktPsRoCgyXicxSosn5wAjP K4k3NDE0tzQ0MrawMDcyUhLnnfrhSriQQHpiSWp2ampBahFMHxMHp1QDo3a6fMdS7Y11OzNc uq/1ZV5yOFqk/7/uDusNFa6Y7Jgb3K72e5K3zwoT+dGoNV/LLKM8t6xOUmEC73Wda4qC2w48 XzLnwsM/c/dkzdmlt3zL+x/dPq73Kjm7fa9zCfw4vUxo80xu3+/u59pYePK2/ZympdT+73fR hn17Iqe8fmORoPREQK8tWImlOCPRUIu5qDgRAMgJuly4AgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170228115202eucas1p229ce302beb5a3ebe0cf12b563c61f15d X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?UTF-8?B?UGV0ZXIgU3RlcGhlbnNvbhtTQ1NDLURhdGEgUGxhbmUb?= =?UTF-8?B?7IK87ISx7KCE7J6QG1ByaW5jaXBhbCBFbmdpbmVlciwgU29mdHdhcmU=?= X-Global-Sender: =?UTF-8?B?UGV0ZXIgU3RlcGhlbnNvbhtTQ1NDLURhdGEgUGxhbmUbU2Ft?= =?UTF-8?B?c3VuZyBFbGVjdHJvbmljcxtQcmluY2lwYWwgRW5naW5lZXIsIFNvZnR3YXJl?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDA1Q0QwNTAwNTg=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170228112804epcas2p2e241ff0013d6ac1cae21987a41442ce8 X-RootMTR: 20170228112804epcas2p2e241ff0013d6ac1cae21987a41442ce8 References: <1488280289.2878360.895324176.3971EE76@webmail.messagingengine.com> <1488281256.2881475.895357184.6106CE5C@webmail.messagingengine.com> On Tue, 28 Feb 2017 03:27:36 -0800 Sebastian Gniazdowski wrote: > Checked that even: > > [[ "below" = "below" ]] && (( line ++ )) || (( line = stborder )) > > doesn't fire. In the same way. It is the false option that is fired: Ah, I see what you've done now. I moved this to zsh-users because this is an interesting point and the above should give folks enough context to see what I'm talking about; look at zsh-workers for more background. && and || don't work the way they do in C, they are simply evaluated left to right in a symmetric fashion. (Yes, another shell oddity dating from year zero for Ray to moan about.) Have a look at the grammar tests for some example. In detail: - Test succeeds. - So (( line ++ )) run - line was zero, and with a post increment the value is zero, so status is 1. - (This is the unexpected bit.) On a non-zero status, the shell looks forward for the next ||, ignoring any &&'s. As I said, there is no relative priority, just a strict left to right evaluation. - So it then executes (( line = stborder )) - I'm guessing stborder is 0, so that's what line is set to. You *could* fix this up by switching to a pre-increment, but I'd recommend just going to if/then/else --- it's much more obvious what the logic actually means. pws