Boolean check on Bash¶
Overview¶
#!/bin/bash
# There are a lot of work behind the boolean conditions check with Bash.
# More idea captured: https://stackoverflow.com/questions/2953646/how-can-i-declare-and-use-boolean-variables-in-a-shell-script
# Below returned different values.
# Failed
if [[ true && true && true && false ]];
then echo 1
else echo 2
fi;
# Worked
if true && true && true && false;
then echo 1
else echo 2
fi;