OSDN Git Service

import nethack-3.6.0
[jnethack/source.git] / sys / unix / nethack.sh
1 #!/bin/sh
2 # NetHack 3.6  nethack.sh       $NHDT-Date: 1432512789 2015/05/25 00:13:09 $  $NHDT-Branch: master $:$NHDT-Revision: 1.17 $
3
4 HACKDIR=/usr/games/lib/nethackdir
5 export HACKDIR
6 HACK=$HACKDIR/nethack
7 # NB: MAXNROFPLAYERS is deprecated in favor of MAXPLAYERS in SYSCF.
8 MAXNROFPLAYERS=4
9
10 # Since Nethack.ad is installed in HACKDIR, add it to XUSERFILESEARCHPATH
11 case "x$XUSERFILESEARCHPATH" in
12 x)      XUSERFILESEARCHPATH="$HACKDIR/%N.ad"
13         ;;
14 *)      XUSERFILESEARCHPATH="$XUSERFILESEARCHPATH:$HACKDIR/%N.ad"
15         ;;
16 esac
17 export XUSERFILESEARCHPATH
18
19 # Get font dir added, but only once (and only if there's an xset to be found).
20 test -n "$DISPLAY" -a -e $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
29 if test \( "xxx$PAGER" != xxx \) -a \( "xxx$HACKPAGER" = xxx \)
30 then
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
64 fi
65
66
67 cd $HACKDIR
68 case $1 in
69         -s*)
70                 exec $HACK "$@"
71                 ;;
72         *)
73                 exec $HACK "$@" $MAXNROFPLAYERS
74                 ;;
75 esac