#!/bin/sh
# if there is an argument, find maxima_toc.html

PATH="/cygdrive/c/Program Files/Maxima-5.9.2/bin:$PATH"
PATH="/cygdrive/c/Program Files/Maxima-5.9.3/bin:$PATH"
export PATH

MAXIMA=`type -p maxima 2>/dev/null`
if [ $? -eq 0 ]
then
  if [ -f "/usr/bin/cygwin1.dll" ]
  then
    if [ "$1" ]
    then
      maxima.bat -d | grep -F 'maxima-htmldir=' | \
        sed -e 's/maxima-htmldir=/"/' -e 's|$|/maxima_toc.html"|' \
	    -e 's|\\|/|g' -e 's|C:|/cygdrive/c/|'
    else
      echo '("cygwin")'
    fi
  else
    if [ "$1" ]
    then
      maxima -d | grep -F 'maxima-htmldir=' | sed -e \
        's/maxima-htmldir=/"/' -e 's|$|/maxima_toc.html"|'
    else
      maxima --list-avail | sed -e '1d' -e 's/version /"/' \
        -e 's/, lisp / /' -e 's/$/"/' -e '2s/^/(/' -e '$s/$/)/'
    fi
  fi
else
  # maxima not found
  echo '#f'
fi
