diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/launch.sh | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/launch.sh b/src/launch.sh index 01f56c2..467bd26 100644 --- a/src/launch.sh +++ b/src/launch.sh @@ -2,6 +2,7 @@ # Launch script for unix systems, loads bundled libraries if there are any. EXIT_STATUS=0 +TMPDIR=${TMPDIR:-/tmp} failed() { zenity --error --text="The program appears to not have closed correctly. Please check output.log to see details." @@ -9,7 +10,6 @@ failed() { } run_game() { - cd "$(dirname "$0")" || return 1 PAYLOAD_LINE="$(awk '/^__PAYLOAD_BEGINS__/ { print NR + 1; exit 0; }' "$0")" || return 1 tail -n +"${PAYLOAD_LINE}" "$0" | xz -d > "$TMPFILE" || return 1 chmod +x "$TMPFILE" || return 1 @@ -17,13 +17,17 @@ run_game() { return 0 } -TMPDIR=/tmp -TMPFILE="$(mktemp /tmp/Pong-XXXXXXXXXXXXXXXXXXXXX)" +cd "$(dirname "$0")" || exit 1 +trap '{ rm -rf "$TMPFILE"; }' EXIT +if ! TMPFILE="./$(mktemp .Pong-XXXXXX)"; +then + echo "Can't extract Pong binary to current directory. Trying $TMPDIR" + TMPFILE="$(mktemp "$TMPDIR"/Pong-XXXXXX)" +fi if ! run_game; then failed fi -rm "$TMPFILE" exit "$EXIT_STATUS" __PAYLOAD_BEGINS__ |