#!/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 <https://github.com/hanslub42/rlwrap>." >& 1
    exit 1
fi


if [ "true" = "true" ]; then
  MAXIMA_SHAREDIR="/opt/local/share/maxima/5.47.0/share"
else
  MAXIMA_SHAREDIR="/opt/local/var/macports/build/maxima-0dc76224/work/maxima-5.47.0/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
