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


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

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

Started byL A Walsh <bash@tlinx.org>
First post2018-05-31 14:22 -0700
Last post2018-05-31 14:22 -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" L A Walsh <bash@tlinx.org> - 2018-05-31 14:22 -0700

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

FromL A Walsh <bash@tlinx.org>
Date2018-05-31 14:22 -0700
SubjectRe: Conditions with logical operators and nested groups execute "if" and "else"
Message-ID<mailman.882.1527801734.1292.bug-bash@gnu.org>

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, || checks the exit status of the last command that was 
> executed.
>
> And as your example shows, 'cmd1 && cmd2 || cmd3' is not the same as
> 'if cmd1; then cmd2; else cmd3' which was the comparison this thread 
> started with.
>   
Yes, you are right.  I was confusing exit status with integer status
in my example.

His code example is further complicated by the fact that cmd2
is never true, and his reduction only is applied once, which
doesn't seem right.



[toc] | [standalone]


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


csiph-web