$ bash -ec 'if [ 1 = 2 ]; then echo true; fi; echo $?' 0 $ bash -ec '[ 1 = 2 ] && echo true; echo $?' 1