discuss: Incorrect AND / OR Precedence


Previous by date: 9 Dec 2021 08:59:32 +0000 Incorrect AND / OR Precedence, Bulgrien, Dennis
Next by date: 9 Dec 2021 08:59:32 +0000 Found an problem with, https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/panels.html#PANELMOVERESIZE, Tom
Previous in thread: 9 Dec 2021 08:59:32 +0000 Incorrect AND / OR Precedence, Bulgrien, Dennis
Next in thread:

Subject: Re: Incorrect AND / OR Precedence
From: "Ian! D. Allen" ####@####.####
Date: 9 Dec 2021 08:59:32 +0000
Message-Id: <YbHFbF/mFheXXj5q@idallen-oak.home.idallen.ca>

On Thu, Sep 16, 2021 at 10:41:49AM -0400, Bulgrien, Dennis wrote:
> Please double-check https://tldp.org/LDP/abs/html/opprecedence.html which states that && AND has higher precedence that || OR. Other web sites and my experience indicate your documentation is incorrect. In the example below, if && was executed first then echo would have to run to complete the expression prior to running false, but in actuality echo does not run because || runs first and short-circuit condition says there is no point in running echo.
> 
> $ false || false && echo y

Those are "list operators", not logical operators.
From "man bash":

"Of these list operators, && and || have equal precedence"

Your example never executes the echo no matter what the precedence of
the operators is:

$  { false || false ; } && echo y
(no output)

$ false || { false && echo y ; }
(no output)

-- 
| Ian! D. Allen, BA, MMath  -  ####@####.####  - Ottawa, Ontario, Canada
| Home: www.idallen.com  Contact Improvisation Dance: www.contactimprov.ca
| Former college professor (Free/Libre GNU+Linux) at:  teaching.idallen.com
| Improve democracy: www.fairvote.ca and Defend digital freedom: www.eff.org

Previous by date: 9 Dec 2021 08:59:32 +0000 Incorrect AND / OR Precedence, Bulgrien, Dennis
Next by date: 9 Dec 2021 08:59:32 +0000 Found an problem with, https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/panels.html#PANELMOVERESIZE, Tom
Previous in thread: 9 Dec 2021 08:59:32 +0000 Incorrect AND / OR Precedence, Bulgrien, Dennis
Next in thread:


  ©The Linux Documentation Project, 2014. Listserver maintained by dr Serge Victor on ibiblio.org servers. See current spam statz.