我发布了我的剧本:
::::::脚本::::::
clear
echo -e '\E[44m'"Testing case conditions"; tput sgr0
until [ "$vpm" = "n" ]; do
read -p "Do you want to continue (Y/n): " vpm
case $vpm in
"Y" | "y" | "yes" | "Yes" | "YES" | "yES" | "yeS" | "YeS" | "YEs" | "yEs")
read -p "Pass your string: " sin
clear
echo -e '\E[42m'"$sin"; tput sgr0
sleep 3
;;
"n")
echo "Exit"
;;
* )
#echo "Invalid parameter" #At this line if user enter any thing else except of yes /n the script print invalid parameter but I want to break it after 3rd wrong input.**
;;
esac
done
exit 1
我想在第三次输入无效参数后退出此脚本。请指导我如何做到这一点。
答案 0 :(得分:0)
为了清晰(并重复使用),将“是”比较代码放入函数中。
如果接听,您可以尽早for int Retries = 1 to 3
和exit
/ break
。