我在這裏以下一些教程,每當我執行,我得到這bash腳本是給我的錯誤,我想不通爲什麼
Do you want to create a bukkit server on this computer? (Hint: answer YES or NO) > no
answered no
./test.sh: line 44: syntax error near unexpected token `else'
./test.sh: line 44: 'else'
這裏的腳本:
while true; do
read -p "Do you want to create a bukkit server on this computer? (Hint: answer YES or NO) > " yn
case $yn in
[Yy]*) echo answered yes; INSTALL="Y"; break;;
[Nn]*) echo answered no; break;;
*) echo "Please answer yes or no.";;
esac
done
if [ -z "$INSTALL" ];
echo "Yay!"
else
echo "Sadface!"
fi
我是一個新手的bash:/
您可能還需要_explicitly_你的循環之前清楚'INSTALL'以防一些其他的代碼已經設置。如果它被設置爲_anything_並且你回答「否」,結果將不會是你所期望的。 – paxdiablo 2012-07-24 02:35:42