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