forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cataclysm-launcher
executable file
·52 lines (44 loc) · 1.05 KB
/
cataclysm-launcher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
printerr() {
echo "ERROR: $*" >&2
}
TARGET_FILE=$0
cd "$(dirname "$TARGET_FILE")" || {
printerr "Could not change directory to '$TARGET_FILE'"
exit 1
}
TARGET_FILE="$(basename "$TARGET_FILE")"
# Iterate down a (possible) chain of symlinks.
while [ -L "$TARGET_FILE" ]
do
TARGET_FILE="$(readlink "$TARGET_FILE")"
cd "$(dirname "$TARGET_FILE")" || {
printerr "Could not change directory to '$TARGET_FILE'"
exit 1
}
TARGET_FILE="$(basename "$TARGET_FILE")"
done
# Find the physical path and name of target file.
DIR=$(pwd -P)
BIN=$(basename "$0")
cd "$DIR" || {
_errcode=$?
printerr "Could not change directory to '$DIR'"
exit $_errcode
}
# If name does not match a binary or is this same script, find the right one
if [ ! -f "$BIN" ] || [ "$BIN" = "cataclysm-launcher" ]
then
BIN=
for bin in cataclysm-tiles cataclysm
do
[ -f "$bin" ] && BIN="$bin" && break
done
fi
if [ "$BIN" ]
then
exec ./$BIN "$@"
else
printerr "Couldn't find cataclysm game binary in '$DIR'/"
exit 1
fi