Weired 'syntax error: unexpected end of file' in bash script

前端 未结 4 735
孤城傲影
孤城傲影 2021-01-27 23:37

I can\'t figure out what is wrong with following script.

#!/bin/bash 
if [ \"$1\" = \"x\" ] 
then
  echo Pushing web on sharada to origin.
else if [ \"$1\" = \"y         


        
4条回答
  •  时光取名叫无心
    2021-01-27 23:44

    It should be elif, not else if, as shown below:

    if [ "$1" = "x" ] 
    then
      echo Pushing web on sharada to origin.
    elif [ "$1" = "y" ] 
    then 
      echo Pulling web on sharada from origin.
    else 
      echo "Usage : arg x to push or y to pull."
    fi
    

提交回复
热议问题