From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Users' List <zsh-users@zsh.org>
Subject: Re: [BUG] Condition in [[ doesn't fire, with "if" it fires
Date: Wed, 01 Mar 2017 12:01:32 +0000 [thread overview]
Message-ID: <20170301120132.79921498@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20170228115158.727f67ff@pwslap01u.europe.root.pri>
On Tue, 28 Feb 2017 11:51:58 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> On Tue, 28 Feb 2017 03:27:36 -0800
> Sebastian Gniazdowski <psprint3@fastmail.com> wrote:
> > Checked that even:
> >
> > [[ "below" = "below" ]] && (( line ++ )) || (( line = stborder ))
> >
> > doesn't fire. In the same way. It is the false option that is fired:
>
> && and || don't work the way they do in C, they are simply evaluated
> left to right in a symmetric fashion.
While that's true, I suppose I ought to point out, for anyone trying to
learn something from this, that in this particular case the logic
happens to work the same as C. zsh does { X && Y } || Z because of left
to right evaluation, C does (X && Y) || Z beause of precedence.
The oddity causing the problem was the (( ... )) return status non-zero,
rather than the logical ordering, which is a rather different point.
Where it's very different from C is
X || Y && Z
which is effectively { X || Y } && Z in zsh, because it's simply left
to right, and X || (Y && Z) in C because of precedence. There's nothing
to stop you writing X || { Y && Z } in zsh to group explicitly, however.
Now back to normal service.
pws
prev parent reply other threads:[~2017-03-01 12:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1488280289.2878360.895324176.3971EE76@webmail.messagingengine.com>
[not found] ` <CGME20170228112804epcas2p2e241ff0013d6ac1cae21987a41442ce8@epcas2p2.samsung.com>
[not found] ` <1488281256.2881475.895357184.6106CE5C@webmail.messagingengine.com>
2017-02-28 11:51 ` Peter Stephenson
2017-02-28 12:17 ` Sebastian Gniazdowski
2017-03-01 12:01 ` Peter Stephenson [this message]
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=20170301120132.79921498@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.com \
--cc=zsh-users@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).