这是脚本,我不断收到意外的错误。我错过了什么? ..(我开始使用[]作为if语句,但由于我正在使用此命令,我删除了[] ..这样可以吗?)
if type "java" 2>&1;
then
echo "All ok . . . ";
exit
else
read -n1 -r -p "Yo need to install"
while true; do
echo "Want to install??"
select yn in "y" "n"; do
case $yn in
y ) echo "Installing here..."; break;;
n ) echo "Ok... stopping..."; exit;;
esac
done
exit
fi
谢谢!
答案 0 :(得分:3)
while
以done
而不是exit
结尾。试试这个:
if type "java" 2>&1;
then
echo "All ok . . . ";
exit
else
read -n1 -r -p "Yo need to install"
while true; do
echo "Want to install??"
select yn in "y" "n"; do
case $yn in
y ) echo "Installing here..."; break;;
n ) echo "Ok... stopping..."; exit;;
esac # <-- ending `case`
done # <-- ending `select`
done # <-- while ends with `done`, not `exit`!
fi # <-- ending `if`
答案 1 :(得分:1)
你在exit
之前有一个fi
;我想这应该是done
。