Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I'm new to Linux so this probably should be an easy fix, but I cannot see it.

I have a script downloaded from official sources that is used to install additional tools for fsharp but it gives me a syntax error when running it.

I tried to replace ( and ) by { and } but eventually it lead me to another error so I think this is not the problem since the script works for everybody. I read some articles that say that my bash version maybe is not the right one.

I'm using Ubuntu 10.10 and here is the error: 28: Syntax error: "(" unexpected (expecting "}")

And this is line 27, 28 and 29:

  declare -a DIRS=("${!3}")

And the full script:

#! /bin/sh -e


    echo "$1" >&2
    echo "Installation aborted." >&2
    exit 1

echo "This script will install additional material for F# including"
echo "man pages, fsharpc and fsharpi scripts and Gtk# support for F#"
echo "Interactive (root access needed)"
echo ""

# ------------------------------------------------------------------------------
# Utility function that searches specified directories for a specified file
# and if the file is not found, it asks user to provide a directory


  declare -a DIRS=("${!3}")
  for TRYDIR in ${DIRS[@]}
    if [ -f $TRYDIR/$FILE ]

  while [ ! -f $DIR/$FILE ]
    echo "File '$FILE' was not found in any of ${DIRS[@]}. Please enter $1 installation directory:"
    read DIR

# ------------------------------------------------------------------------------
# Locate F# installation directory - this is needed, because we want to 
# add environment variable with it, generate 'fsharpc' and 'fsharpi' and also
# copy load-gtk.fsx to that directory
# ------------------------------------------------------------------------------

PATHS=( $1 /usr/lib/fsharp /usr/lib/shared/fsharp )
searchpaths "F# installation" FSharp.Core.dll PATHS[@]
echo "Successfully found F# installation directory."

# ------------------------------------------------------------------------------
# Check that we have everything we need
# ------------------------------------------------------------------------------

[ $(id -u) -eq 0 ] || die "Please run the script as root."
which mono > /dev/null || die "mono not found in PATH."

# ------------------------------------------------------------------------------
# Make sure that all additional assemblies are in GAC
# ------------------------------------------------------------------------------

echo "Installing additional F# assemblies to the GAC"
gacutil -i $FSHARPDIR/FSharp.Build.dll
gacutil -i $FSHARPDIR/FSharp.Compiler.dll
gacutil -i $FSHARPDIR/FSharp.Compiler.Interactive.Settings.dll
gacutil -i $FSHARPDIR/FSharp.Compiler.Server.Shared.dll

# ------------------------------------------------------------------------------
# Install additional files
# ------------------------------------------------------------------------------

# Install man pages

echo "Installing additional F# commands, scripts and man pages"
mkdir -p $MAN
cp *.1 $MAN

# Export the FSHARP_COMPILER_BIN environment variable

if [[ ! "$OSTYPE" =~ "darwin" ]]; then
  mv /etc/profile.d/

# Generate 'load-gtk.fsx' script for F# Interactive (ask user if we cannot find binaries)

PATHS=( /usr/lib/mono/gtk-sharp-2.0 /usr/lib/cli/gtk-sharp-2.0 /Library/Frameworks/Mono.framework/Versions/2.8/lib/mono/gtk-sharp-2.0 )
searchpaths "Gtk#" gtk-sharp.dll PATHS[@]
echo "Successfully found Gtk# root directory."

PATHS=( /usr/lib/mono/gtk-sharp-2.0 /usr/lib/cli/glib-sharp-2.0 /Library/Frameworks/Mono.framework/Versions/2.8/lib/mono/gtk-sharp-2.0 )
searchpaths "Glib" glib-sharp.dll PATHS[@]
echo "Successfully found Glib# root directory."

PATHS=( /usr/lib/mono/gtk-sharp-2.0 /usr/lib/cli/atk-sharp-2.0 /Library/Frameworks/Mono.framework/Versions/2.8/lib/mono/gtk-sharp-2.0 )
searchpaths "Atk#" atk-sharp.dll PATHS[@]
echo "Successfully found Atk# root directory."

PATHS=( /usr/lib/mono/gtk-sharp-2.0 /usr/lib/cli/gdk-sharp-2.0 /Library/Frameworks/Mono.framework/Versions/2.8/lib/mono/gtk-sharp-2.0 )
searchpaths "Gdk#" gdk-sharp.dll PATHS[@]
echo "Successfully found Gdk# root directory."

cp bonus/load-gtk.fsx load-gtk1.fsx
sed "s,INSERTGTKPATH,$GTKDIR,g" load-gtk1.fsx > load-gtk2.fsx
sed "s,INSERTGDKPATH,$GDKDIR,g" load-gtk2.fsx > load-gtk3.fsx
sed "s,INSERTATKPATH,$ATKDIR,g" load-gtk3.fsx > load-gtk4.fsx
sed "s,INSERTGLIBPATH,$GLIBDIR,g" load-gtk4.fsx > load-gtk.fsx
rm load-gtk1.fsx
rm load-gtk2.fsx
rm load-gtk3.fsx
rm load-gtk4.fsx
mv load-gtk.fsx $FSHARPDIR/load-gtk.fsx

# Generate 'fsharpc' and 'fsharpi' scripts (using the F# path)
# 'fsharpi' automatically searches F# root directory (e.g. load-gtk)

echo "#!/bin/sh" > fsharpc
echo "exec mono $FSHARPDIR/fsc.exe --resident \"\$@\"" >> fsharpc
chmod 755 fsharpc

echo "#!/bin/sh" > fsharpi
echo "exec mono $FSHARPDIR/fsi.exe -I:\"$FSHARPDIR\" \"\$@\"" >> fsharpi
chmod 755 fsharpi

mv fsharpc $BIN/fsharpc
mv fsharpi $BIN/fsharpi

Thanks a lot!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Change the first line from

#! /bin/sh -e


#!/bin/bash -e
share|improve this answer
The reason for this change is that Ubuntu uses dash as it default shell, not bash as expected by the script writer. – Javier Rivera Jan 11 '11 at 18:59
Still got the same error :( – tucaz Jan 11 '11 at 19:31
Wow! I ran it with "sudo bash" and it worked! Thanks! Why did it work? – tucaz Jan 11 '11 at 19:34
@tucaz Well, Javier Rivera pointed out one reason. I guess maybe the other is that does not have execute permissions ( 'ls -la' )? So passing the script as an argument to BASH worked. – user8290 Jan 11 '11 at 19:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.