0
3つの関数がすべてゼロを返す場合にのみ実行するbash if文を取得できません。私は簡単な例を作って、実行するために底部にあるif文を得ることができませんでした(コードのelse部分が実行されます)。 if文を間違って設定していますか?bashでANDを使用して複数の関数の戻り値を連結する
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
ありがとう、それは働いた! – isaac9A