![两个 Case 语句相互嵌套,我想返回第一个 case](https://linux22.com/image/13006/%E4%B8%A4%E4%B8%AA%20Case%20%E8%AF%AD%E5%8F%A5%E7%9B%B8%E4%BA%92%E5%B5%8C%E5%A5%97%EF%BC%8C%E6%88%91%E6%83%B3%E8%BF%94%E5%9B%9E%E7%AC%AC%E4%B8%80%E4%B8%AA%20case.png)
我正在尝试将一个 case 语句放入另一个像这样的 case 语句中并拥有它,以便用户可以返回到第一个 case 语句(如果他们愿意)
read choice
case $choice in
1)
read pattern
case $pattern in
pattern1)
Statement()
;;
pattern2)
Statement(return to the first case)
;;
*)
echo "Error"
;;
esac
;;
2)
echo "test"
;;
3)
break
;;
*)
echo "error"
;;
esac
答案1
像下面这样:
while true; do
read -rp "Your Question? [1|2|3] " choice
case $choice in