I've been using Bash for a long time, but it seems I still miss something. Please consider this code:
function surprise {
true && {
echo 'Expected';
false;
} || {
echo 'Unexpected';
}
}
surprise;
which is shortened demonstration of my real problem and the output:
Expected
Unexpected
Till now I have thought, that whatever "Expected" block returns does not affect ||
in front of the "Unexpected" block, but it seems, like ||
is not checked against the output of true
command, but in fact of the false
command inside brackets.
Can someone, please, explain, what actually just happened? Thank you in advance.