[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Conditions with logical operators and nested groups execute "if" and
Re: Conditions with logical operators and nested groups execute "if" and "else"
Thu, 31 May 2018 20:05:12 +0700
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0
On 05/31/2018 01:54 PM, Robert Elz wrote:
> I am not sure what predence rule you see working as
> expected, but in sh (bash, or any other Bourne syntax
> or POSIX shell) there is no precedence for && and ||
> they (in the absense of grouping) are simply executed
> left to right as written.
Here is an easy way to figure out how and/or-lists work: Given that &&
and || have the lowest precedence of all operators (except for ; and &),
they can be thought of as concatenating commands/blocks/pipelines, and
the execution rule for an and/or-list is:
If the exit-status of the command/block/pipeline is 0, continue after
the next &&, otherwise continue after the next || in the and/or-list.