我试图做出一个简单的选择来选择一些东西。
但是我有错误,有人可以帮助我吗?
$ vi sel2.sh
lagi='y'
while [ $lagi == 'y' ] || [ $lagi == 'Y' ];
do
clear
select menu in "Bakso" "Gado-Gado" "Exit";
case $REPLY in
1) echo -n "Banyak mangkuk =";
read jum
let bayar=jum*1500;
;;
2) echo -n "Banyak porsi =";
read jum
let bayar=jum*2000;
;;
3) exit 0
;;
*) echo "Sorry, tidak tersedia"
;;
esac
do
echo "Harga bayar = Rp. $bayar"
echo "THX"
echo
echo -n "Hitung lagi (y/t) :";
read lagi;
#untuk validasi input
while [ $lagi != 'y' ] && [ $lagi != 'Y' ] && [ $lagi != 't' ] && [ $lagi != 'T' ];
do
echo "Ops, isi lagi dengan (y/Y/t/Y)";
echo -n "Hitung lagi (y/t) :";
read lagi;
done
done
最佳答案
尝试改变
select menu in "Bakso" "Gado-Gado" "Exit";
至
options=( "Bakso" "Gado-Gado" "Exit")
select menu in "${options[@]}"
关于linux - Bash Linux上的错误选择菜单,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47118857/