tash
tash

Reputation: 11

Why am I getting this unexpected token error?

This is how my code goes. However I keep getting this error. I am not sure why. Could someone kindly help me?

syntax error near unexpected token `echo'

Upvotes: 0

Views: 519

Answers (1)

chepner
chepner

Reputation: 530960

Whitespace is important here. { is only special if it is a word by itself. What you have here is an attempt to define a function named localiser{, but with the simple command echo ... as the body. Function bodies must be compound commands (usually { ... }).

Defining a function with the function keyword isn't really recommended; it exists many for compatibility with ksh. Use the following form instead:

localiser () {
    ...
}

Upvotes: 1

Related Questions