我有一个问题从功能回到主菜单。我的BASH脚本看起来像这样
function functionA(){
while [ "$choice" != x ]; do
echo "Press a to take action, and press b to exit and go back to the main list"
read choice
case $choice in
a)
echo "Now lets do some stuff"
read
...
.....
;;
x)
exit
esac
done
}
while [ "$choice" != x ];do
echo "Main list"
echo "Press a to go to functionA, press b to go to functionB, and press x to exit the program"
read choice
case $choice in
a) functionA
;;
b) functionB
;;
c) exit
esac
done
所以基本上,如果用户在functionA()
并按x
退出,我希望他回到主列表,然后他就可以去{{1} }再次或functionA()
,或者再次按functionB()
退出整个程序。
答案 0 :(得分:3)
当您在x
中输入function()
时,您正在exit
中调用functionA()
,这会使整个脚本退出。而只是return
。