1#!/bin/sh
2# NetHack 3.7  nethack.sh	$NHDT-Date: 1596498294 2020/08/03 23:44:54 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.21 $
3# Copyright (c) 2015 by Kenneth Lorber, Kensington, Maryland
4# NetHack may be freely redistributed.  See license for details.
5
6HACKDIR=/usr/games/lib/nethackdir
7export HACKDIR
8HACK=$HACKDIR/nethack
9
10# Since Nethack.ad is installed in HACKDIR, add it to XUSERFILESEARCHPATH
11case "x$XUSERFILESEARCHPATH" in
12x)	XUSERFILESEARCHPATH="$HACKDIR/%N.ad"
13	;;
14*)	XUSERFILESEARCHPATH="$XUSERFILESEARCHPATH:$HACKDIR/%N.ad"
15	;;
16esac
17export XUSERFILESEARCHPATH
18
19# Get font dir added, but only once (and only if there's an xset to be found).
20test -n "$DISPLAY" -a -f $HACKDIR/fonts.dir && xset p >/dev/null 2>&1 && (
21	xset fp- $HACKDIR >/dev/null 2>&1;
22	xset fp+ $HACKDIR
23)
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
68exec $HACK "$@"
69