[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Conditions with logical operators and nested groups execute "if" and
L A Walsh
Re: Conditions with logical operators and nested groups execute "if" and "else"
Thu, 31 May 2018 14:22:03 -0700
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
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
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.