#!/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="/usr/share/maxima/5.47.0/share"
else
  MAXIMA_SHAREDIR="/mnt/share/cygpkgs/maxima/maxima.x86_64/build/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
