mardi 28 avril 2015

syntax error in conditional expression: unexpected token `;'

I have a shell script that should accept multiple arguments

It can either accept the argument "update" or "create". If no argument is passed, the user should get an error. However, when building my if/elif condition I'm getting the error

syntax error in conditional expression: unexpected token;'`

firstParam=$1
echo $firstParam //update/create/{empty}

if [[ "$firstParam" == "" ]]; then
    printf "${RED}Use this script as \"tzfrs update/new [projectName]\"${NC} \n"
    exit 1
elif [[ "$firstParam" == "update"]]; then
  printf "update"
  exit 1
fi

If I have the script like this

if [[ "$firstParam" == "" ]]; then
    printf "${RED}Use this script as \"tzfrs update/new [projectName]\"${NC} \n"
    exit 1
fi

The error handling works, and I'm seeing the following message

Use this script as "tzfrs update/new [projectName]"

However, when adding the elif condition I'm getting the above error. Anyone any idea?

Aucun commentaire:

Enregistrer un commentaire