bash文件的意外结束


read answer #this will read what the user is typing in and makes a string for it
if [[ -z {answer} ]] 
then 
echo "Sorry that is not a valid choice, please select from the above list provided" #this will help pick up if the user just enters a blank option
if [[ $1{answer} ]]
then 
echo "this has worked" #no clue if this will work going to try this and see if it works
if [[ $2{answer} ]]
then 
echo "this is answer 2"
if [[ $3{answer} ]]
then
echo "this is answer 3"
if [[ $4{answer} ]]
then 
echo "This is answer 4"
if [[ $Q{answer} ]] 
then 
echo "this is the quit button"
else 
echo "no valid choice has been made"
fi
fi
fi
fi
fi
fi

所以我试图运行这段代码,我为每个if语句都有结束参数,但每次我尝试运行它时,它都会显示"第51行:语法错误:意外结束文件"代码一直到第50行,我试着输入;;但是它在它们上运行了一个语法错误,我试着用dos2unix命令转换,但什么也没有,我错过了什么吗?

$添加到该行,如下所示

if [[ -z ${answer} ]]

最新更新