728x90
stigala
July 12th, 2007, 04:33 AM
Hi, 

I'm trying to run a script on ubuntu 7.04;

stig@stig-laptop:~/mosesdecoder$ ./regenerate-makefiles.sh 
./regenerate-makefiles.sh: 13: Syntax error: "(" unexpected

but then I get the syntax error. Below is the first lines in the script, line 13 in red. 



#!/bin/sh

# NOTE:
# Versions 1.9 (or higher) of aclocal and automake are required.

# For Mac OSX users:
# Standard distribution usually includes versions 1.6.
# Get versions 1.9 or higher
# Set the following variable to the correct paths
#ACLOCAL="/path/to/aclocal-1.9"
#AUTOMAKE="/path/to/automake-1.9"

function die () {
echo "$@" >&2
exit 1
}

...

I already have automake (GNU automake 1.9.6) and aclocal (GNU automake 1.9.6). Setting the paths is only for Mac OSX users, so I didn't try to set any of those paths. 

Anyone can explain this? Thanks for any help,

Stig
Rui Pais
July 12th, 2007, 05:01 AM
Hi.

the (inexistent) problem is the 1st line in combination with Ubuntu. 

When you run it using ./ it will use the shell you mention on first line, in your case:
#!/bin/sh

if you do a ls -l /bin/sh you will see that it's just a link to dash.
Ubuntu, since Edgy, replaced old sh with dash, creating a series of incompatibilities in a lot of scripts...

So, either you run:
bash regenerate-makefiles.sh 

or replace first line with:
#!/bin/bash
(or even remove the 1st line and environment will call it with bash)

or (losing generality) adapt it for dash:
remove the keyword function:
die() {
...
}

hth

구닥다리 dash로 실행되는 녀석을 bash로 실행되도록 해놓으란 말

파일의 첫줄을

#!/bin/sh ==> #!/bin/bash

이렇게 바꾸니까 된다.

728x90

+ Recent posts