#!/bin/sh
# -*- Shell-script -*-

RLWRAP=rlwrap
type $RLWRAP > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
    echo "$0 error: rmaxima requires rlwrap." >& 1
    echo "rlwrap is available from <http://utopia.knoware.nl/~hlub/uck/rlwrap/>." >& 1
    exit 1
fi


if [ "true" = "true" ]; then
  MAXIMA_SHAREDIR=/usr/local/share/maxima/5.36.1/share
else
  MAXIMA_SHAREDIR=/usr/obj/ports/maxima-5.36.1/maxima-5.36.1/share
fi

MAXIMA_BUILTINS=$MAXIMA_SHAREDIR/builtins-list.txt

if [ -f $MAXIMA_BUILTINS ]; then
  exec rlwrap --always-readline --complete-filenames --break-chars '(){}[].,*/+-=&^$#@\;|´`:' --file $MAXIMA_BUILTINS --remember maxima --disable-readline "$@"
else
  echo "$0: failed to locate list of built-in symbols; go ahead without it."
  echo "$0: (I thought it might be $MAXIMA_BUILTINS but there is no such file.)"
  exec rlwrap --always-readline --complete-filenames --break-chars '(){}[].,*/+-=&^$#@\;|´`:' --remember maxima --disable-readline "$@"
fi
