set_menu_choice() {
clear
echo "Options :-"
echo
echo " a) Add new CD"
echo " f) Find CD"
echo " c) Count the CDs and tracks in the catalog"
echo
echo -e "Please enter choice the press return \c"
read menu_choice
return
}
echo "Mini CD manager"
sleep 1
quit=n
while [ "$quit" != "y" ]
do
set_menu_choice
case "$menu_choice" in
q | Q) quit=y;;
*) echo "Sorry, choice not regconized";;
esac
done
echo "Finished"
exit 0
当输入q的时候,能够正常退出;可是当输入其他字符,却不能正常匹配第二个星号选项
请看看是什么原因导致呢?~初学者,请指教
While 死循环会永远执行(输入q 或Q 时会结束脚本),由于每次不是正常退出是都会调用setmenuchoice 执行 clear ,所以你上一条的 *)匹配被清屏了,你终端再往上拉进度条就能看到。