ternary construction not equivalent with if then else
问题 The following if/then test (in bash): if [ 1 ]; then ls /undef_dummy > /dev/null 2>&1; else echo "else stmt"; fi seems not equivalent to its ternary version: (test 1) && ls /undef_dummy > /dev/null 2>&1 || echo "else stmt" The first one will print nothing but the second one will print "else stmt". This is because the || operator in the ternary version relates to the return status of either the test or the command executed if the test passes. But usually, we want the else statement to only