#!/bin/sh -xeu # Launch script for unix systems, loads bundled libraries if there are any. EXIT_STATUS=0 TMPDIR=${TMPDIR:-/tmp} failed() { ERROR_TEXT="The program appears to not have closed correctly. Please check output.log to see details." zenity --error --text="$ERROR_TEXT" || echo "$ERROR_TEXT" EXIT_STATUS=1 } run_game() { PAYLOAD_LINE="$(awk '/^__PAYLOAD_BEGINS__/ { print NR + 1; exit 0; }' "$0")" || return 1 tail -n +"${PAYLOAD_LINE}" "$0" | gzip -d > "$TMPFILE" || return 1 chmod +x "$TMPFILE" || return 1 DYLD_LIBRARY_PATH=libs/ LD_LIBRARY_PATH=libs/ "$TMPFILE" > output.log 2>&1 || return 1 return 0 } cd "$(dirname "$0")" || exit 1 trap '{ rm -rf "$TMPFILE"; }' EXIT HUP INT QUIT TERM 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 exit "$EXIT_STATUS" __PAYLOAD_BEGINS__