0

私はここでいくつかのチュートリアルに従っています、そして私がこれを実行するときはいつでも、私は得ます

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初心者です:/

4

2 に答える 2

2

then条件の後にキーワードがありません:

if [ -z "$INSTALL" ]; then
    echo "Yay!"
else
    echo "Sadface!"
fi
于 2012-07-24T02:14:36.140 に答える
1

thenの後にが必要ですif:

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" ]; then
echo "Yay!"
else
echo "Sadface!"
fi
于 2012-07-24T02:15:44.440 に答える