如何在子shell命令失敗時終止shell。如何在子shell命令失敗時終止一個shell?
例如:
check(){
if [ $1 -eq $1 2> /dev/null ]; then
echo "returning 0"
return 0
else
echo "returning 1"
return 1
fi
}
if [ "($check $1)" == 1 ]; then
echo "Error: with proper message"
exit
fi
if [ "$1" -le 1000 ] || [ "$2" -ge 10000 ]; then
echo "Error:"
exit
fi
我在這裏傳遞字符串和第一,如果條件失敗,並且如果第二條件與在命令行錯誤執行「整數表達預期」。 我知道()子shell命令失敗,但外殼沒有終止。如何在子shell命令失敗時從shell中退出。
感謝您的信息.. – Shriram