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# copy default config file to home directory if none
19# exists for unnethack or vanilla
20if [ ! -e "$HOME/.unnethackrc" -a ! -e "$HOME/.nethackrc" ]
21then
22	cp "$HACKDIR/unnethackrc.default" "$HOME/.unnethackrc"
23fi
24
25# see if we can find the full path name of PAGER, so help files work properly
26# assume that if someone sets up a special variable (HACKPAGER) for NetHack,
27# it will already be in a form acceptable to NetHack
28# ideas from brian@radio.astro.utoronto.ca
29if test \( "xxx$PAGER" != xxx \) -a \( "xxx$HACKPAGER" = xxx \)
30then
31
32	HACKPAGER=$PAGER
33
34#	use only the first word of the pager variable
35#	this prevents problems when looking for file names with trailing
36#	options, but also makes the options unavailable for later use from
37#	NetHack
38	for i in $HACKPAGER
39	do
40		HACKPAGER=$i
41		break
42	done
43
44	if test ! -f $HACKPAGER
45	then
46		IFS=:
47		for i in $PATH
48		do
49			if test -f $i/$HACKPAGER
50			then
51				HACKPAGER=$i/$HACKPAGER
52				export HACKPAGER
53				break
54			fi
55		done
56		IFS=' 	'
57	fi
58	if test ! -f $HACKPAGER
59	then
60		echo Cannot find $PAGER -- unsetting PAGER.
61		unset HACKPAGER
62		unset PAGER
63	fi
64fi
65
66
67cd $HACKDIR
68case $1 in
69	-s*)
70		exec $HACK "$@"
71		;;
72	*)
73		exec $HACK "$@" $MAXNROFPLAYERS
74		;;
75esac
76