#!/bin/bash
#############################################################################
##
##  gap.sh                      GAP                          Martin Schoenert
##
##  This is a shell script for the  UNIX  operating system  that starts  GAP.
##  This is the place  where  you  make  all  the  necessary  customizations.
##  Then copy this file to a  directory in your  search path,  e.g., '~/bin'.
##  If you later move GAP to another location you must only change this file.
##
##  modified for Debian by Bill Allombert <ballombe@debian.org>

GAP_LIB="$HOME/gap;/usr/local/lib/gap;/usr/local/share/gap;/usr/lib/gap;/usr/share/gap"


#############################################################################
##
##  GAP_PRG . . . . . . . . . . . . . . . . .  name of the executable program
##
##  Set 'GAP_PRG' to the  name of the executable  program of the  GAP kernel.
##  The  default is  '`hostname'/gap'.    You  can   either change this    to
##  '<target>/gap' where <target> is the  target you have selected during the
##  compilation or create  a symbolic link  from <target> to  '`hostname`' in
##  the 'bin' directory.
##

if [ "x$GAP_PRG" = "x" ];  then
GAP_PRG=@GAP_PRG@
fi

#############################################################################
##
##  GAP_WORKSPACE . . . . . . . . . . . .  command to load a saved workspace
##
##

for dir in $HOME/gap /var/lib/gap; do
  GAP_WORKSPACE=$dir/workspace
  if [ -f $GAP_WORKSPACE ];  then
    exec  $GAP_PRG -l "$GAP_LIB" -L $GAP_WORKSPACE "$@"
  elif [ -f $GAP_WORKSPACE.gz ];  then
    exec  $GAP_PRG -l "$GAP_LIB" -L <(zcat $GAP_WORKSPACE.gz) "$@"
  fi
done

#############################################################################
##
##  GAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . run GAP
##
##  You  probably should  not change  this line,  which  finally starts  GAP.
##
exec $GAP_PRG -l "$GAP_LIB" "$@"
