0

我正在发布我的脚本:

::::::脚本::::::

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

我想在第三次输入无效参数后退出此脚本。请指导我如何做到这一点。

4

1 回答 1

0

为清楚起见(和重用),将“是”比较代码放入函数中。

如果回答,您可能会提前执行for int Retries = 1 to 3, 和exit/ 。break

于 2013-09-17T13:40:23.440 回答