Skip to content

Instantly share code, notes, and snippets.

@rcxdude
Created January 16, 2015 01:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rcxdude/1f6257e0a965147a462c to your computer and use it in GitHub Desktop.
diff --git a/steam_broken.sh b/steam.sh
index ab7ec1a..49e2213 100755
--- a/steam_broken.sh
+++ b/steam.sh
@@ -1,7 +1,12 @@
#!/usr/bin/env bash
+set -e
+set -o pipefail
+shopt -s failglob
+set -u
+
# Allow us to debug what's happening in the script if necessary
-if [ "$STEAM_DEBUG" ]; then
+if [ "${STEAM_DEBUG-}" ]; then
set -x
fi
export TEXTDOMAIN=steam
@@ -17,7 +22,7 @@ ARCHIVE_EXT=tar.xz
STEAMROOT="$(cd "${0%/*}" && echo $PWD)"
STEAMDATA="$STEAMROOT"
-if [ -z $STEAMEXE ]; then
+if [ -z ${STEAMEXE-} ]; then
STEAMEXE=`basename "$0" .sh`
fi
# Backward compatibility for server operators
@@ -36,7 +41,7 @@ MINIMUM_STEAMSCRIPT_VERSION=100020
# Save the system paths in case we need to restore them
export SYSTEM_PATH="$PATH"
-export SYSTEM_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
+export SYSTEM_LD_LIBRARY_PATH="${LD_LIBRARY_PATH-}"
function show_message()
{
@@ -403,7 +408,7 @@ function get_missing_libraries()
# We couldn't run the link loader for this architecture
echo "libc.so.6"
else
- LD_PRELOAD= ldd "$1" | grep "=>" | grep -v linux-gate | grep -v / | awk '{print $1}'
+ LD_PRELOAD= ldd "$1" | grep "=>" | grep -v linux-gate | grep -v / | awk '{print $1}' || true
fi
}
@@ -511,8 +516,8 @@ fi
# identify Linux distribution and pick an optimal bin dir
PLATFORM=`detect_platform`
-PLATFORM32=`echo $PLATFORM | fgrep 32`
-PLATFORM64=`echo $PLATFORM | fgrep 64`
+PLATFORM32=`echo $PLATFORM | fgrep 32 || true`
+PLATFORM64=`echo $PLATFORM | fgrep 64 || true`
if [ -z "$PLATFORM32" ]; then
PLATFORM32=`echo $PLATFORM | sed 's/64/32/'`
fi
@@ -537,6 +542,7 @@ STEAMDATALINK="`detect_steamdatalink`" # points at the Steam content path
STEAMSTARTING="$STEAMCONFIG/starting"
# Was -steamos specified
+: "${STEAMOS:=}"
if steamos_arg $@; then
STEAMOS=1
fi
@@ -544,9 +550,11 @@ fi
# See if this is the initial launch of Steam
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE") 2>/dev/null; then
INITIAL_LAUNCH=true
+else
+ INITIAL_LAUNCH=false
fi
-if [ "$1" = "--reset" ]; then
+if [ "${1-}" = "--reset" ]; then
reset_steam
exit
fi
@@ -556,13 +564,15 @@ if [ "$INITIAL_LAUNCH" ]; then
show_license_agreement
# See if we need to update the /usr/bin/steam script
- if [ -z "$STEAMSCRIPT" ]; then
+ if [ -z "${STEAMSCRIPT:-}" ]; then
STEAMSCRIPT="/usr/bin/`detect_package`"
fi
if [ -f "$STEAMSCRIPT" ]; then
if ! check_scriptversion "$STEAMSCRIPT" STEAMSCRIPT_VERSION "$MINIMUM_STEAMSCRIPT_VERSION"; then
STEAMSCRIPT_OUTOFDATE=1
warn_outofdate
+ else
+ STEAMSCRIPT_OUTOFDATE=""
fi
fi
@@ -611,15 +621,16 @@ echo "Running Steam on $(distro_description)"
# as possible, so feel free to tinker with it and submit patches and
# bug reports.
#
+: "${STEAM_RUNTIME:=}"
if [ "$STEAM_RUNTIME" = "debug" ]; then
# Use the debug runtime if it's available, and the default if not.
export STEAM_RUNTIME="$STEAMROOT/$PLATFORM/steam-runtime"
if unpack_runtime; then
- if [ -z "$STEAM_RUNTIME_DEBUG" ]; then
+ if [ -z "${STEAM_RUNTIME_DEBUG-}" ]; then
STEAM_RUNTIME_DEBUG="$(cat "$STEAM_RUNTIME/version.txt" | sed 's,-release,-debug,')"
fi
- if [ -z "$STEAM_RUNTIME_DEBUG_DIR" ]; then
+ if [ -z "${STEAM_RUNTIME_DEBUG_DIR-}" ]; then
STEAM_RUNTIME_DEBUG_DIR="$STEAMROOT/$PLATFORM"
fi
if [ ! -d "$STEAM_RUNTIME_DEBUG_DIR/$STEAM_RUNTIME_DEBUG" ]; then
@@ -674,7 +685,7 @@ if [ "$STEAM_RUNTIME" -a "$STEAM_RUNTIME" != "0" ]; then
;;
esac
- export LD_LIBRARY_PATH="$STEAM_RUNTIME/i386/lib/i386-linux-gnu:$STEAM_RUNTIME/i386/lib:$STEAM_RUNTIME/i386/usr/lib/i386-linux-gnu:$STEAM_RUNTIME/i386/usr/lib:$STEAM_RUNTIME/amd64/lib/x86_64-linux-gnu:$STEAM_RUNTIME/amd64/lib:$STEAM_RUNTIME/amd64/usr/lib/x86_64-linux-gnu:$STEAM_RUNTIME/amd64/usr/lib:$LD_LIBRARY_PATH"
+ export LD_LIBRARY_PATH="$STEAM_RUNTIME/i386/lib/i386-linux-gnu:$STEAM_RUNTIME/i386/lib:$STEAM_RUNTIME/i386/usr/lib/i386-linux-gnu:$STEAM_RUNTIME/i386/usr/lib:$STEAM_RUNTIME/amd64/lib/x86_64-linux-gnu:$STEAM_RUNTIME/amd64/lib:$STEAM_RUNTIME/amd64/usr/lib/x86_64-linux-gnu:$STEAM_RUNTIME/amd64/usr/lib:${LD_LIBRARY_PATH-}"
else
echo "Unpack runtime failed, error code $?"
show_message --error $"Couldn't set up the Steam Runtime. Are you running low on disk space?\nContinuing..."
@@ -704,7 +715,7 @@ MAGIC_RESTART_EXITCODE=42
SEGV_EXITCODE=139
# and launch steam
-STEAM_DEBUGGER=$DEBUGGER
+STEAM_DEBUGGER="${DEBUGGER-}"
unset DEBUGGER # Don't use debugger if Steam launches itself recursively
if [ "$STEAM_DEBUGGER" == "gdb" ] || [ "$STEAM_DEBUGGER" == "cgdb" ]; then
ARGSFILE=$(mktemp $USER.steam.gdb.XXXX)
@@ -737,7 +748,7 @@ if [ "$UNAME" = "Linux" ]; then
if [ "$INITIAL_LAUNCH" -a \
$STATUS -ne $MAGIC_RESTART_EXITCODE -a \
-f "$STEAMSTARTING" -a \
- -z "$STEAM_INSTALLED_BOOTSTRAP" -a \
+ -z "${STEAM_INSTALLED_BOOTSTRAP-}" -a \
-z "$STEAMSCRIPT_OUTOFDATE" ]; then
# Launching the bootstrap failed, try reinstalling
if reset_steam; then
@ScoreUnder
Copy link

They forgot to quote line 24 (going by patch line numbers).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment