#!/bin/sh

#
#	This script selects an appropriate version of the On-Line Help
#	system to run, depending on the user's display type and machine
#	type.
#
#	$Source: /afs/rel-eng.athena.mit.edu/project/release/current/source/athena/athena.bin/olh/RCS/olh.script,v $
#	$Author: lwvanels $
#	$Header: /afs/rel-eng.athena.mit.edu/project/release/current/source/athena/athena.bin/olh/RCS/olh.script,v 1.4 91/07/31 14:37:59 lwvanels Exp $
#

case $DISPLAY in
	"")
	style=ascii
	;;
	*)
	style=motif
	;;
esac

args=

for i in $* ; do
	case $i in
	-n* | -a* | -t*)
		style=ascii
		;;
	-x* | -m* )
		style=motif
		;;
	*)
		args="$args $i"
		;;
	esac
done

case $style in
	motif)
	case `/bin/athena/machtype -c` in
	MVAX-II | VAXSTAR)
		args="${args} -xrm Olh.useViewers:False"
		;;
	esac
	;;
esac

olh_program=/usr/athena/bin/olh_${style}

if [ -f ${olh_program} ]; then
	/bin/athena/attach -q -n logos
	$olh_program $args $xargs && exit 0
	case $style in
	motif)
		cat 1>&2 << EOF
----------------------------------------------------
Program ${olh_program} exited with an error.
Please type help -tty to use the text version of On-Line Help.
EOF
		;;
	ascii)
		cat 1>&2 << EOF
----------------------------------------------------
Program ${olh_program} exited with an error.
Please call 3-4435 if you need help.
EOF
		;;
	esac
	exit 2
fi

cat 2>&1 << EOF
----------------------------------------------------
Could not find help program "${olh_program}".
To use the text-based version of On-Line Help, type help -tty.
If help -tty fails, call 3-4435 for help.
EOF
exit 1
