#! /bin/sh -e

# Copyright (C) 2007,2010 by Michael Hanke michael.hanke@gmail.com
# Copyright (C) 2009 by Mark Hymers <mark.hymers@ynic.york.ac.uk>
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

cmd=${0##*/}

if [ "${cmd}" = "fsl_app_wrapper" ]; then
    echo 'fsl_app_wrapper: This script should not be run like this, see fsl-5.0(1) for details' 1>&2
    exit 1
fi

# Set up the FSL paths if necessary
# do not allows user-override, as this wrapper is used via
# versioned symlinks
. /etc/fsl/5.0/fsl.sh

abs_cmd=${FSLDIR}/bin/${cmd}
if [ ! -x $abs_cmd ]; then
	# try stripping major version prefix
	abs_cmd=${FSLDIR}/bin/${cmd#fsl5.0-*}
fi

exec ${abs_cmd} $@
