by cesnja · 3y ago · 0 comments
if [ a = b ]; then
echo "Oops!"
fi
will do exactly what you imagined, but [ a = b ] && echo "Oops!"
will quit with an error if expression a does not equal expression b. $ bash -ec 'if [ 1 = 2 ]; then echo true; fi; echo $?'
0
$ bash -ec '[ 1 = 2 ] && echo true; echo $?'
1
In both cases it does not quite and execute the last echo.