Given your trying to check that a variable is not empty and not some other value as in the following code:
if [ ! -z "$foo" ] && [[ ${foo} != "bar" ]]; then
what is the best practice for accomplishing this. I've seen bash conditionals written several ways including the following...
if [[ ! -z "$foo" && ${foo} != "bar" ]]; then
I understand there is a difference when using the single brackets and the double, I'm more concerned with when to put the &&
or ||
inside the brackets or out.