Why does this not work as expected?
$ false && { echo ok; echo ok; } && { echo notOK; }
and this not:
$ false && { echo ok; echo ok; } || { echo notOK; }
I don't see it!
Why does this not work as expected?
$ false && { echo ok; echo ok; } && { echo notOK; }
and this not:
$ false && { echo ok; echo ok; } || { echo notOK; }
I don't see it!
This is how &&
and ||
work.
&&
executes the right-hand-side if the left-hand-side finished with a "true" value (0).
||
executes the right-hand-side if the left-hand-side finished with a "false" value (! 0).
false && { echo ok; echo ok } || { echo notOK; }
Is processed this way:
false
returns 1&&
does not execute `{ echo ok; echo ok }' because the left-hand-side was not 0||
does execute { echo notOK; }
because the left-hand-side was not 0