#1552 adm/unixsetup script fails with error on Linux

qualidafial Mon 6 Jun 2011

The last few times I've installed/upgraded Fantom I've tried using the unixsetup script but always get this error:

matt@matt:~/apps/fantom/fantom-1.0.59$ sh adm/unixsetup 
adm/../bin/fanlaunch: 66: Syntax error: "(" unexpected

For reference, here is line 66 from fanlaunch:

function read_prop()
{
  eval "$1='`sed '/^\#/d' "$FAN_HOME/etc/sys/config.props" | sed '/^\/\//d' | grep \"$2=\"  | tail -n 1 | sed 's/^[^=]*=//;s/^[[:space:]]*//;s/[[:space:]]*$//'`'"
}

I'm not super experienced in bash scripting so I'll leave it to others to point out what the problem is.

In practice the workaround is easy: just set the execute permission on each script in the bin/ folder, and add the bin/ folder to $PATH. But it would be nice if the unixsetup script just worked out of the box. :)

brian Mon 6 Jun 2011

Yeah I suck at Bash too, I believe that code originated as a patch from someone in the community. But if someone who knows Bash, sed, etc can send me a fix I'll be happy to push to hg for next build.

qualidafial Mon 6 Jun 2011

Per this page you can use either function keyword or parentheses, but not both. I removed the function keyword from line 66 and the script ran perfectly.

brian Mon 6 Jun 2011

can you post that a diff so I patch it exactly right? thanks

qualidafial Mon 6 Jun 2011

Here you go:

diff -r f3aec934509c bin/fanlaunch
--- a/bin/fanlaunch	Fri Jun 03 08:40:50 2011 -0400
+++ b/bin/fanlaunch	Mon Jun 06 16:08:19 2011 -0600
@@ -63,7 +63,7 @@
 fi

 # read a single line property from $FAN_HOME/etc/sys/config.props
-function read_prop()
+read_prop()
 {
   eval "$1='`sed '/^\#/d' "$FAN_HOME/etc/sys/config.props" | sed '/^\/\//d' | grep \"$2=\"  | tail -n 1 | sed 's/^[^=]*=//;s/^[[:space:]]*//;s/[[:space:]]*$//'`'"
 }
@@ -75,4 +75,4 @@
   shift
   read_prop JAVA_OPTIONS java.options
   "$FAN_JAVA" $osFlags $JAVA_OPTIONS $libPath -cp "$FAN_CP":"$CLASSPATH" -Dfan.home="$FAN_HOME" "$FAN_MAIN" "$@"
-}
\ No newline at end of file
+}

brian Tue 7 Jun 2011

Ok thanks, pushed your patch changeset

Login or Signup to reply.