On Thu, May 12, 2022, at 11:34 PM, flyingrhino wrote: > Should the "else" condition after the: || run if the last command in > the: && section exits non zero?
Yes. This behavior is not a bug; ''A && B || C'' is simply not equivalent to ''if A then B; else C; fi''. https://mywiki.wooledge.org/BashPitfalls#pf22 > Script: > > > #!/bin/bash > > [[ "a" == "a" ]] && \ > { > echo "equal" > ls x > } || { > echo "***** SHOULD NOT DISPLAY 4" > } > > > Result: > > ./moo.sh > equal > ls: cannot access 'x': No such file or directory > ***** SHOULD NOT DISPLAY 4 This behavior is expected and correct. There is no bug here. > BTW, I've checked other conditions as follows and they look ok: > > [...] > > [[ "a" == "a" ]] && \ > { > echo "equal" > } || { > echo "***** SHOULD NOT DISPLAY 1" > } This would display "***** SHOULD NOT DISPLAY 1" if ''echo "equal"'' failed for some reason. (Unlikely but possible.) -- vq