Bash 意外标记“elif'”附近出现语法错误;(`elif[$ver==8];然后';)

Bash 意外标记“elif'”附近出现语法错误;(`elif[$ver==8];然后';),bash,shell,unix,sed,Bash,Shell,Unix,Sed,这是该程序的来源,但当我试图启动它时,我犯了错误: #!/bin/bash ########################## help ############################# # # -njc (Do not crawl if java is installed) # # # ############################################################# #function function pause(){

这是该程序的来源,但当我试图启动它时,我犯了错误:

#!/bin/bash

########################## help #############################
# 
# -njc (Do not crawl if java is installed)
#
#
#
#############################################################




#function
function pause(){
   read -p "$*"
}


## echo info
warn="\e[39m[\e[33mWarn\e[39m]"
error="\e[39m[\e[91mERROr\e[39m]"
info="\e[39m[\e[34mInfo\e[39m]"
quest="\e[39m[\e[32mQuestion\e[39m]"

###------------------------------


## check java
if ! echo "-njc" | grep -q "$*"; then ## se non attivato fai:
    if type -p java; then
        _java=java
        elif [ -n "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ];  then
        _java="$JAVA_HOME/bin/java"
        else
        echo -e $warn "No java version found. Please install java and try again."
        echo
        pause 'Press [Enter] key to continue...'
        exit
    fi
fi

clear
#------------question
##Create server directory
echo -e $quest "Enter the name of the folder where the server will be created. [Default is NewServer]"
read namedir
if [ -z "$namedir" ]; then
    mkdir NewServer > /dev/null
    cd NewServer > /dev/null
    else
    mkdir $namedir > /dev/null
    cd $namedir > /dev/null
fi

echo -e $quest "Choose the spigot version. [Default is Latest]"
echo
echo ".----List of verion----."
echo "| 1) Latest            |"
echo "|                      |"
echo "| 2) 1.11              |"
echo "| 3) 1.10              |"
echo "| 4) 1.9.4             |"
echo "| 5) 1.9.2             |"
echo "| 6) 1.9               |"
echo "| 7) 1.8.8             |"
echo "| 8) 1.8.7             |"
echo "| 9) 1.8.3             |"
echo "| 10) 1.8              |"
echo "#----------------------#"
echo
read ver
if [ -z "$ver" ]; then
    version="latest"
    elif [ $ver == 1]; then
    version="latest"
    elif [ $ver == 2]; then
    version="1.11"
    elif [ $ver == 3]; then
    version="1.10"
    elif [ $ver == 4]; then
    version="1.9.4"
    elif [ $ver == 5]; then
    version="1.9.2"
    elif [ $ver == 6]; then
    version="1.9"
    elif [ $ver == 7]; then: 
    version="1.8.8"
    elif [ $ver == 8]; then
    version="1.8.7"
    elif [ $ver == 9]; then
    version="1.8.3"
    elif [ $ver == 10]; then
    version="1.8"
    else 
    echo -e $warn "The choice is invalid."
    echo
    pause 'Press [Enter] key to continue...'
    exit
fi



echo -e $info "Java found"

## Download BuildTools.jar and remove old version
echo -e $info "Removing old versions of BuildTools.jar"
rm BuildTools.jar > /dev/null
echo -e $info "Downloading the latest version of BuildTools.jar. Please wait."
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastCompletedBuild/artifact/target/BuildTools.jar
echo -e $info "Download finished"

## Starting BuildTools.jar
echo -e $info "Spigot download has begun. Please wait"
sleep 3
java -jar BuildTools.jar --rev $version
echo -e $info "The spigot download is finished."

Pause 'Press [Enter] key to continue...'
当我从这个错误开始时:

./newscript.sh: line 89: syntax error near unexpected token `elif'
./newscript.sh: line 89: `      elif [ $ver == 8]; then'
我已经设置了chmod,并且已经用dos2unix转换了它 我还尝试了命令:
catspiget-Install.sh | sed'/\015/d'>newscript.sh

我怎样才能修好它

elif [ $ver == 7]; then: 
version="1.8.8"
elif [ $ver == 8]; then
version="1.8.7"`

elif[$ver==7]行中;然后:
您有
之后,这是导致错误的原因。只需删除
并在conditions中的每个
]
前面加上空格。

此外,
]
前面缺少空格。您可以考虑使用bash内置
选择vname[in word…];do列表;已完成
,用于进行选择。