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

2018-05-31 Thread L A Walsh
Ilkka Virta wrote: If the 1st expression is false, it would skip directly to the '||' and would execute the 3rd clause. If the 1st expresion is true then it does the 2nd clause. If that is false, the '||' clause is done, but if true, the '||' clause would not be done. In other words, ||

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

2018-05-31 Thread PePa
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

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

2018-05-31 Thread Ilkka Virta
On 31.5. 02:20, L A Walsh wrote: Ilkka Virta wrote: On 22.5. 00:17, Uriel wrote: As you know, a conditional is of the type: if [[ EXPRESSION ]]; then TRUE CONDITION; else ALTERNATIVE RESULT; fi Or with logical operators and groups: [[ EXPRESSION ]] && { TRUE CONDITION; } || { ALTERNATIVE RES

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

2018-05-31 Thread Greg Wooledge
On Wed, May 30, 2018 at 05:02:58PM -0700, L A Walsh wrote: > Greg Wooledge wrote: > > On Mon, May 21, 2018 at 04:17:18PM -0500, Uriel wrote: > > > [[ EXPRESSION ]]; && { TRUE CONDITION; } || { ALTERNATIVE RESULT; } > > https://mywiki.wooledge.org/BashPitfalls#pf22 > pf22 is wrong. It's not wrong.

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

2018-05-31 Thread Robert Elz
Date:Wed, 30 May 2018 17:02:58 -0700 From:L A Walsh Message-ID: <5b0f3bb2.1000...@tlinx.org> | I.e. precedence rules seem to work as expected. I am not sure what predence rule you see working as expected, but in sh (bash, or any other Bourne syntax or POSIX shell)

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

2018-05-30 Thread L A Walsh
uriel: You didn't say what you expected the behavior to be in your bottom conditional, but remember, you start with -e-e-e--debug; you lop off the 1st -e (did you mean to use ## instead of #?) so last statement of 1st indent was ! "-e-e--debug =~ ^- so the regex matches (true) and then you say '

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

2018-05-30 Thread L A Walsh
Ilkka Virta wrote: On 22.5. 00:17, Uriel wrote: As you know, a conditional is of the type: if [[ EXPRESSION ]]; then TRUE CONDITION; else ALTERNATIVE RESULT; fi Or with logical operators and groups: [[ EXPRESSION ]] && { TRUE CONDITION; } || { ALTERNATIVE RESULT; } No, those are no

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

2018-05-22 Thread Greg Wooledge
On Mon, May 21, 2018 at 04:17:18PM -0500, Uriel wrote: > [[ EXPRESSION ]]; && { TRUE CONDITION; } || { ALTERNATIVE RESULT; } https://mywiki.wooledge.org/BashPitfalls#pf22

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

2018-05-22 Thread Ilkka Virta
On 22.5. 00:17, Uriel wrote: As you know, a conditional is of the type: if [[ EXPRESSION ]]; then TRUE CONDITION; else ALTERNATIVE RESULT; fi Or with logical operators and groups: [[ EXPRESSION ]] && { TRUE CONDITION; } || { ALTERNATIVE RESULT; } No, those are not the same. In the latter, the

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

2018-05-21 Thread Pierre Gaston
On Tue, May 22, 2018 at 12:17 AM, Uriel wrote: > Configuration Information: > Machine: x86_64 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' > -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/s