dist/freedoom: support ~/.local installs, make it easier to read paths

Bunch of logic to use XDG_DATA_HOME or fallback according to the
actual XDG recommendations.

Use an array to build up paths (can be edited easily in the future or
for whatever custom purpose), which shellcheck warned is a bash-ism,
so change the script interpreter to bash as well.  Let’s hope that
doesn’t break anyone (does anyone lack bash even if they don’t use it
as their shell?)
This commit is contained in:
Mike Swanson 2019-09-07 01:52:47 -07:00
parent 5a9483c329
commit d9a1ff3e78

22
dist/freedoom vendored
View file

@ -1,4 +1,4 @@
#!/bin/sh -
#!/bin/bash -
# These ports should really be ordered by ease-of-use. Most likely
# advanced users with many ports installed will invoke their preferred
@ -32,7 +32,25 @@ case "$(basename "$0")" in
esac
if [ -z "$DOOMWADPATH" ]; then
export DOOMWADPATH="/usr/share/doom:/usr/share/games/doom:/usr/local/share/doom:/usr/local/share/games/doom"
# Support installations of Freedoom to the home directory using
# the XDG spec. Makes this complicated, but lets do it right.
if [ -z "$XDG_DATA_HOME" ]; then
if [ -z "$HOME" ]; then
HOME=/
fi
XDG_PATH="$HOME"/.local/share/games/doom
else
XDG_PATH="$XDG_DATA_HOME"/games/doom
fi
PATHS=(
"$XDG_PATH"
/usr/local/share/games/doom
/usr/local/share/doom
/usr/share/games/doom
/usr/share/doom
)
export DOOMWADPATH="$(echo "${PATHS[@]}" | tr ' ' :)"
fi
if [ -z "$DOOMPORT" ] && [ -h "$HOME"/.doomport ]; then