#!/bin/sh
#
# Mathematica 4.0 command file
#
# Copyright 1988 - 1999  Wolfram Research, Inc.
#

spath=`expr $0'/' : '\(/\)[^/]*//*$' \| $0'/' : \
            '\(.*[^/]\)//*[^/][^/]*//*$' \| .`

if [ "." = $spath ]; then
   MPATH=`pwd`
else
   if [ .`(echo $spath | grep "^/")` = .$spath ]; then
      MPATH=$spath
   else
      MPATH="`pwd`/$spath"
   fi
fi

sysid=`basename $MPATH`

topdir=`\cd $MPATH/../../Files; pwd`
bindir=$topdir/SystemFiles/Kernel/Binaries/$sysid

PATH=$PATH:$topdir/../Executables/Linux:$topdir/SystemFiles/Graphics/Binaries/Linux
export PATH

XFILESEARCHPATH=$topdir/SystemFiles/Graphics/TextResources/English/%N
export XFILESEARCHPATH

if [ "$PSRESOURCEPATH" != "" ] ; then
   PSRESOURCEPATH="$PSRESOURCEPATH:"
fi
PSRESOURCEPATH=$PSRESOURCEPATH$topdir/SystemFiles/Fonts/Type1:$topdir/SystemFiles/Graphics/SystemResources
export PSRESOURCEPATH

if [ ! -x $bindir/MathKernel ]; then
   echo "Mathematica kernel executable "
   echo "$bindir/MathKernel"
   echo "not found.  Your Mathematica installation may be incomplete"
   echo "or corrupted.  Note that you must call this script directly,"
   echo "and not through a symbolic link."
   exit
fi

exec $parent_process $bindir/MathKernel -runfirst "\$TopDirectory=\"$topdir\"" "$@"
