mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-12-29 13:22:21 +01:00
75 lines
1.7 KiB
Bash
Executable File
75 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
set -u
|
|
|
|
die () { echo "nethack:" "$@" >&2 ; exit 1 ; }
|
|
|
|
[ "x${HOME:-}" = x ] && die "\$HOME not set"
|
|
cd "$HOME"
|
|
[ -d .nethack ] || mkdir -p .nethack
|
|
cd .nethack
|
|
[ -f nhdat ] || ln -s /usr/share/nethack/nhdat nhdat
|
|
[ -d save ] || mkdir -p save
|
|
[ -f logfile ] || : > logfile
|
|
[ -f perm ] || : > perm
|
|
[ -f record ] || : > record
|
|
|
|
HACKDIR="$HOME/.nethack"
|
|
export HACKDIR
|
|
HACK=/usr/lib/nethack/nethack
|
|
MAXNROFPLAYERS=4
|
|
|
|
# Since Nethack.ad is installed in HACKDIR, add it to XUSERFILESEARCHPATH
|
|
case "x${XUSERFILESEARCHPATH:-}" in
|
|
x) XUSERFILESEARCHPATH="$HACKDIR/%N.ad"
|
|
;;
|
|
*) XUSERFILESEARCHPATH="$XUSERFILESEARCHPATH:$HACKDIR/%N.ad"
|
|
;;
|
|
esac
|
|
export XUSERFILESEARCHPATH
|
|
|
|
# see if we can find the full path name of PAGER, so help files work properly
|
|
# assume that if someone sets up a special variable (HACKPAGER) for NetHack,
|
|
# it will already be in a form acceptable to NetHack
|
|
# ideas from brian@radio.astro.utoronto.ca
|
|
if test \( "xxx${PAGER:-}" != xxx \) -a \( "xxx${HACKPAGER:-}" = xxx \)
|
|
then
|
|
HACKPAGER="$PAGER"
|
|
# use only the first word of the pager variable
|
|
# this prevents problems when looking for file names with trailing
|
|
# options, but also makes the options unavailable for later use from
|
|
# NetHack
|
|
for i in $HACKPAGER
|
|
do
|
|
HACKPAGER="$i"
|
|
break
|
|
done
|
|
|
|
if test ! -f "$HACKPAGER"
|
|
then
|
|
IFS=:
|
|
for i in $PATH
|
|
do
|
|
if test -f "$i/$HACKPAGER"
|
|
then
|
|
HACKPAGER="$i/$HACKPAGER"
|
|
export HACKPAGER
|
|
break
|
|
fi
|
|
done
|
|
IFS=' '
|
|
fi
|
|
if test ! -f "$HACKPAGER"
|
|
then
|
|
echo "Cannot find $PAGER -- unsetting PAGER." >&2
|
|
unset HACKPAGER
|
|
unset PAGER
|
|
fi
|
|
fi
|
|
|
|
case "x${1:-}" in
|
|
x-s*) exec "$HACK" "$@" ;;
|
|
x*) exec "$HACK" "$@" "$MAXNROFPLAYERS" ;;
|
|
esac
|