Thursday, April 17, 2014

Resolving Bash Error: syntax error near unexpected token `(' declare -a

Removed
Writing a bash script, I got an error when trying to run it :

syntax error near unexpected token `(' declare -a

My array was declared was :
declare -a persons = ('person1' 'person2')

Even though my code looks correct and nice ;) ,  Unix don't accept it. I was removing the quotes.... but nothing worked.

And finally I find the solution: In fact we shouldn't put any space between = and (.

declare -a persons=('person1' 'person2') 

2 comments :

  1. ça ressemble aux fautes de mes étudiants loooool toujours les espaces

    ReplyDelete
    Replies
    1. Eh bah oui, lorsqu'on est habitue au java, on ne pense pas que les espaces peuvent causer des problemes :D

      Delete

Articles les plus consultés