Scripts: Set errexit to catch errors

This commit is contained in:
Unrud
2022-06-05 14:07:24 +02:00
committed by Matthias Mailänder
parent 7cd0d8c079
commit 946cd8f322
17 changed files with 84 additions and 41 deletions

View File

@@ -1,4 +1,5 @@
#!/bin/sh
set -o errexit || exit $?
HERE="$(dirname "$(readlink -f "${0}")")"

View File

@@ -1,6 +1,7 @@
#!/bin/bash
# OpenRA packaging script for Linux (AppImage)
set -e
set -o errexit || exit $?
command -v tar >/dev/null 2>&1 || { echo >&2 "Linux packaging requires tar."; exit 1; }
command -v curl >/dev/null 2>&1 || command -v wget > /dev/null 2>&1 || { echo >&2 "Linux packaging requires curl or wget."; exit 1; }

View File

@@ -1,4 +1,6 @@
#!/bin/sh
set -o errexit || exit $?
HERE="$(dirname "$(readlink -f "${0}")")"
cd "${HERE}/../lib/openra" || exit 1

View File

@@ -1,4 +1,6 @@
#!/bin/sh
set -o errexit || exit $?
cd "{GAME_INSTALL_DIR}"
mono {DEBUG} OpenRA.Server.dll Game.Mod={MODID} "$@"

View File

@@ -1,4 +1,5 @@
#!/bin/sh
set -o errexit || exit $?
# OpenRA.Utility relies on keeping the original working directory, so don't change directory
HERE="$(dirname "$(readlink -f "${0}")")"

View File

@@ -1,4 +1,6 @@
#!/bin/sh
set -o errexit || exit $?
LAUNCHER=$(readlink -f "${0}")
HERE="$(dirname "${LAUNCHER}")"
cd "${HERE}/../lib/openra" || exit 1
@@ -43,21 +45,23 @@ fi
# Run the game
export SDL_VIDEO_X11_WMCLASS="openra-{MODID}-{TAG}"
./OpenRA Game.Mod={MODID} Engine.LaunchPath="${LAUNCHER}" "${JOIN_SERVER}" "$@"
./OpenRA Game.Mod={MODID} Engine.LaunchPath="${LAUNCHER}" "${JOIN_SERVER}" "$@" && rc=0 || rc=$?
# Show a crash dialog if something went wrong
if [ $? != 0 ] && [ $? != 1 ]; then
if [ "${rc}" != 0 ] && [ "${rc}" != 1 ]; then
LOGS="${XDG_CONFIG_HOME:-${HOME}/.config}/openra/Logs"
if [ ! -d "${LOGS}" ] && [ -d "${HOME}/.openra/Logs" ]; then
LOGS="${HOME}/.openra/Logs"
fi
test -d Support/Logs && LOGS="${PWD}/Support/Logs"
if [ -d Support/Logs ]; then
LOGS="${PWD}/Support/Logs"
fi
ERROR_MESSAGE=$(printf "%s has encountered a fatal error.\nPlease refer to the crash logs and FAQ for more information.\n\nLog files are located in %s\nThe FAQ is available at http://wiki.openra.net/FAQ" "{MODNAME}" "${LOGS}")
if command -v zenity > /dev/null; then
zenity --no-wrap --error --title "{MODNAME}" --no-markup --text "${ERROR_MESSAGE}" 2> /dev/null
zenity --no-wrap --error --title "{MODNAME}" --no-markup --text "${ERROR_MESSAGE}" 2> /dev/null || :
elif command -v kdialog > /dev/null; then
kdialog --title "{MODNAME}" --error "${ERROR_MESSAGE}"
kdialog --title "{MODNAME}" --error "${ERROR_MESSAGE}" || :
elif "${HERE}/gtk-dialog.py" test > /dev/null; then
"${HERE}/gtk-dialog.py" error --title "{MODNAME}" --text "${ERROR_MESSAGE}" 2> /dev/null
else

View File

@@ -1,4 +1,6 @@
#!/bin/sh
set -o errexit || exit $?
cd "{GAME_INSTALL_DIR}"
# Search for server connection
@@ -9,21 +11,23 @@ if [ "${1#${PROTOCOL_PREFIX}}" != "${1}" ]; then
fi
# Run the game
mono {DEBUG} OpenRA.dll Game.Mod={MODID} Engine.LaunchPath="{BIN_DIR}/openra-{MODID}" "${JOIN_SERVER}" "$@"
mono {DEBUG} OpenRA.dll Game.Mod={MODID} Engine.LaunchPath="{BIN_DIR}/openra-{MODID}" "${JOIN_SERVER}" "$@" && rc=0 || rc=$?
# Show a crash dialog if something went wrong
if [ $? != 0 ] && [ $? != 1 ]; then
if [ "${rc}" != 0 ] && [ "${rc}" != 1 ]; then
LOGS="${XDG_CONFIG_HOME:-${HOME}/.config}/openra/Logs"
if [ ! -d "${LOGS}" ] && [ -d "${HOME}/.openra/Logs" ]; then
LOGS="${HOME}/.openra/Logs"
fi
test -d Support/Logs && LOGS="${PWD}/Support/Logs"
if [ -d Support/Logs ]; then
LOGS="${PWD}/Support/Logs"
fi
ERROR_MESSAGE=$(printf "%s has encountered a fatal error.\nPlease refer to the crash logs and FAQ for more information.\n\nLog files are located in %s\nThe FAQ is available at http://wiki.openra.net/FAQ" "{MODNAME}" "${LOGS}")
if command -v zenity > /dev/null; then
zenity --no-wrap --error --title "{MODNAME}" --no-markup --text "${ERROR_MESSAGE}" 2> /dev/null
zenity --no-wrap --error --title "{MODNAME}" --no-markup --text "${ERROR_MESSAGE}" 2> /dev/null || :
elif command -v kdialog > /dev/null; then
kdialog --title "{MODNAME}" --error "${ERROR_MESSAGE}"
kdialog --title "{MODNAME}" --error "${ERROR_MESSAGE}" || :
else
echo "${ERROR_MESSAGE}"
fi