1#!/bin/sh
2#	SCCS Id: @(#)nethack.sh	3.4	1990/02/26
3
4HACKDIR=/usr/games/lib/nethackdir
5export HACKDIR
6HACK=$HACKDIR/nethack
7MAXNROFPLAYERS=4
8
9# Since Nethack.ad is installed in HACKDIR, add it to XUSERFILESEARCHPATH
10case "x$XUSERFILESEARCHPATH" in
11x)	XUSERFILESEARCHPATH="$HACKDIR/%N.ad"
12	;;
13*)	XUSERFILESEARCHPATH="$XUSERFILESEARCHPATH:$HACKDIR/%N.ad"
14	;;
15esac
16export XUSERFILESEARCHPATH
17
18# see if we can find the full path name of PAGER, so help files work properly
19# assume that if someone sets up a special variable (HACKPAGER) for NetHack,
20# it will already be in a form acceptable to NetHack
21# ideas from brian@radio.astro.utoronto.ca
22if test \( "xxx$PAGER" != xxx \) -a \( "xxx$HACKPAGER" = xxx \)
23then
24
25	HACKPAGER=$PAGER
26
27#	use only the first word of the pager variable
28#	this prevents problems when looking for file names with trailing
29#	options, but also makes the options unavailable for later use from
30#	NetHack
31	for i in $HACKPAGER
32	do
33		HACKPAGER=$i
34		break
35	done
36
37	if test ! -f $HACKPAGER
38	then
39		IFS=:
40		for i in $PATH
41		do
42			if test -f $i/$HACKPAGER
43			then
44				HACKPAGER=$i/$HACKPAGER
45				export HACKPAGER
46				break
47			fi
48		done
49		IFS=' 	'
50	fi
51	if test ! -f $HACKPAGER
52	then
53		echo Cannot find $PAGER -- unsetting PAGER.
54		unset HACKPAGER
55		unset PAGER
56	fi
57fi
58
59
60cd $HACKDIR
61case $1 in
62	-s*)
63		exec $HACK "$@"
64		;;
65	*)
66		exec $HACK "$@" $MAXNROFPLAYERS
67		;;
68esac
69