Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 `;' 

The code:

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?

like image 365
Musterknabe Avatar asked Apr 28 '15 09:04

Musterknabe


1 Answers

elif [[ "$firstParam" == "update"]]; then  

should be

elif [[ "$firstParam" == "update" ]]; then 

with a space between "update" and ]]

like image 172
Jahid Avatar answered Sep 22 '22 21:09

Jahid