Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14193 > unrolled thread

Re: Conditions with logical operators and nested groups execute "if" and "else"

Started byPePa <solusos@passchier.net>
First post2018-05-31 20:05 +0700
Last post2018-05-31 20:05 +0700
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Conditions with logical operators and nested groups execute "if" and "else" PePa <solusos@passchier.net> - 2018-05-31 20:05 +0700

#14193 — Re: Conditions with logical operators and nested groups execute "if" and "else"

FromPePa <solusos@passchier.net>
Date2018-05-31 20:05 +0700
SubjectRe: Conditions with logical operators and nested groups execute "if" and "else"
Message-ID<mailman.873.1527781619.1292.bug-bash@gnu.org>
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.

Cheers,
Peter

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web