#! /bin/sh
# file: plt		P. Albrecht and G. Moody	
#			Last revised:	11 April 2001
# This script chooses the correct plt binary (either xplt or lwplt) and runs
# it with the same command-line arguments that were passed to this script.

# First, check for a -T option.
for i in "$@"
do
    if [ "$LAST" = -T ]
    then PTERM="$i"
    fi
    case "$i" in
	-T) ;;
      -Tx*) PTERM="xw" ;;
     -Tlw*) PTERM="lw" ;;
       -T*) echo "$0: unrecognized option" "$i" >/dev/tty; exit ;;
    esac
    LAST="$i"
done

# Next, check to see if running on an X display.
if [ x$DISPLAY != x ]
then PTERM=${PTERM-xw}
fi

# If PTERM still hasn't been set, use the value of the TERM variable.
PTERM=${PTERM-$TERM}
export PTERM

# Finally, choose the binary based on the value of PTERM.
case $PTERM in
     x*) PTERM=xw; exec xplt "$@" ;;
    lw*) PTERM=lw; exec lwplt "$@" ;;
 cygwin) PTERM=lw; exec lwplt "$@" ;;
      *) echo "$0: unrecognized PTERM" >/dev/tty; exit ;;
esac
