help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] && precedence


From: Chet Ramey
Subject: Re: [Help-bash] && precedence
Date: Wed, 9 Aug 2017 18:49:29 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 8/9/17 7:48 AM, Russell Shaw wrote:

> From the horses mouth:
> 
> <http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html>
> 
> 2.9.3 Lists
> 
> An AND-OR list is a sequence of one or more pipelines separated by the
> operators "&&" and "||" .
> 
> A list is a sequence of one or more AND-OR lists separated by the operators
> ';' and '&' and optionally terminated by ';', '&', or <newline>.
> 
> The operators "&&" and "||" shall have equal precedence and shall be
> evaluated with left associativity. For example, both of the following
> commands write solely bar to standard output:
> 
>     false && echo foo || echo bar
>     true || echo foo && echo bar
> 
> --------------
> 
> I think what happens is this.

It gets parsed as if it were entered as '{ true || true; } && echo hi'.
Left associativity, equal precedence.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]