I am having trouble getting a bash if statement to only execute if three functions all return zero. I made a simple example and could not get the if statement at the bottom to run (the else portion of the code runs). Am I setting up the if statement wrong?
test() {
NUM=3
BUM=4
if [ $(NUM) -lt $(BUM) ];
then
return 0;
else
return 1;
fi;
}
test2() {
NUM=4
BUM=5
if [ $(NUM) -lt $(BUM) ];
then
return 0;
else
return 1;
fi;
}
test3() {
NUM=13
BUM=133
if [ $(NUM) -lt $(BUM) ];
then
return 0;
else
return 1;
fi;
}
if [[ ${test} && ${test2} && ${test3} ]]; then
echo "successfully chained function values"
else
echo "ands did not chain successfully"
fi