zsh-users
 help / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: &&||
Date: Tue, 20 Feb 2018 12:28:07 -0800
Message-ID: <CAH+w=7ar21AnR89XtbtaTQtqZYJUvGsQzxcfkDvd2UqJ70=xMw@mail.gmail.com> (raw)
In-Reply-To: <dd60f68c-dddd-1ea3-bc4a-ebcb83173cdf@eastlink.ca>

On Tue, Feb 20, 2018 at 11:24 AM, Ray Andrews <rayandrews@eastlink.ca> wrote:
> On 20/02/18 09:07 AM, Peter Stephenson wrote:
>>
>> You've now extended your demand so that it works with an else clause as
>
> Not 'extended' that is the entire point of my question. I'm expecting the
> '||' to be identical to a logical 'else', there is no other issue.

But "||" is not "else" and "&&" is not "if" -- rather they are "and" /
"or" (which is why they use the symbols they do).

first-statement AND second-statement OR third-statement

The implicit grouping is left-to-right, so that's the same as

{ first-statement AND second-statement } OR third-statement

Thus the first pair succeeds only when both succeed, and
third-statement occurs when the first pair fails.  To express this
with if/else you would write

if first-statement;
then
 if second-statement;
 then
  true;
 else
  false;
 fi;
else
 false;
fi;
if [[ $? -eq 0 ]];
then
 if third-statement;
 then
  true;
 else
  false;
 fi;
else
 false;
fi

> Demand? I seek clarification

I believe PWS meant "demand" in the sense of what your statement asks
of the shell, not what you're asking him to explain.

> Braces are
> ignored as far as truth tests on the left of any && or ||.

No, that's entirely wrong.  Braces always return the final status of
the enclosed list of statements.  && and || always use the final
status of the entire chain of any && or || to their left.  The two are
related only when the braces surround another chain of && or || but
only in so far as that affects the final status of the braces.


  reply index

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-02 15:06 ?????? JEFF BICKLEY
2003-07-02 19:56 ` ?????? Thorsten Haude
2004-11-16 13:45 !!:$ keef
2004-11-16 14:22 ` !!:$ Peter Stephenson
2004-11-16 14:31   ` !!:$ Stephane Chazelas
2004-11-16 15:37   ` !!:$ Bart Schaefer
2004-11-16 16:08     ` !!:$ Peter Stephenson
2004-11-17  0:03 ` !!:$ Bart Schaefer
2004-11-17 19:25   ` !!:$ Danek Duvall
2004-11-18  1:10     ` !!:$ Bart Schaefer
2011-04-25 17:16 反映那些 jcarbas1
2012-06-07  1:51 投稿回复 杨编辑
2014-05-30  8:35 文 章 发 表 马编辑
2014-08-21 21:52 优璇 鄂玉珍
2015-09-08  6:29 !!投稿答复 小郭收稿
2016-03-30 15:48 Насчет нового офиса у Багратионовской Ирина (аренда)
2016-04-11 22:02 По поводу вакансии бухгалтера Наталья Рощина (бух. обслуживание)
2016-04-17 23:24 Нет результатов от раскрутки? Нужно работать, а не ссылки покупать Палашов Михаил
2016-04-21  2:20 По поводу аренды помещения Данилова
2016-05-17  2:34 Офисы по рекордно низким ценам Маслова Наталия
2017-02-12 18:27 Приглашение на конференцию НИЦ \"Открытие\
2017-10-11  3:24 专门服务外贸企业 功能全面的外贸软件 abundantvfzji
2017-10-14  0:38 您还在坐等外贸客户上门吗? notablyubqsh
2017-11-14  8:28 Приглашение на конференцию! Otkritie
2017-11-28 13:36 Otkritie
2018-02-19 21:12 &&|| Ray Andrews
2018-02-19 21:57 ` &&|| Peter Stephenson
2018-02-19 22:47   ` &&|| Ray Andrews
2018-02-20  9:26     ` &&|| Peter Stephenson
2018-02-20  7:54       ` &&|| Ray Andrews
2018-02-20 17:07         ` &&|| Peter Stephenson
2018-02-20 19:24           ` &&|| Ray Andrews
2018-02-20 20:28             ` Bart Schaefer [this message]
2018-02-20 21:45               ` &&|| Ray Andrews
2018-05-12  6:16 Приглашение на конференции и конкурс НИЦ \"Открытие\
2018-06-28 17:36 НИЦ \"Открытие\
2018-10-13  2:54 解決中國進口報關問題!!廉價的貨物儲存倉位!! Peter Yeung
2018-11-28 18:05 Приглашение на конференцию и конкурс НИЦ \"Открытие\
2019-08-21 18:30 Закупки Закупочный процесс

Reply instructions:

You may reply publically 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='CAH+w=7ar21AnR89XtbtaTQtqZYJUvGsQzxcfkDvd2UqJ70=xMw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=rayandrews@eastlink.ca \
    --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

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox