Re: [Help-bash] The difference between 'if cond; then' and 'cond && {'
From:
Greg Wooledge
Subject:
Re: [Help-bash] The difference between 'if cond; then' and 'cond && {'
Date:
Tue, 4 Dec 2018 08:11:25 -0500
User-agent:
NeoMutt/20170113 (1.7.2)
On Mon, Dec 03, 2018 at 04:27:57PM -0700, Bob Proulx wrote:
> Precedence in the shell is strictly left to right for && and ||.
> Therefore one can say:
>
> some_cond && {
> do something1
> do something2
> } || {
> do something3
> do something4
> }
Bad!
> $ true && echo yes || echo no
> yes
BAD!
https://mywiki.wooledge.org/BashPitfalls#pf22
Don't do that.