Skip to content

Instantly share code, notes, and snippets.

@wertercatt

wertercatt/hl.sh Secret

Last active June 22, 2019 06:32
Show Gist options
  • Save wertercatt/5820fe28f9e107a55d6f28929c919c8f to your computer and use it in GitHub Desktop.
Save wertercatt/5820fe28f9e107a55d6f28929c919c8f to your computer and use it in GitHub Desktop.
Steam game shell script testing in osh.
#!/bin/bash
# figure out the absolute path to the script being run a bit
# non-obvious, the ${0%/*} pulls the path out of $0, cd's into the
# specified directory, then uses $PWD to figure out where that
# directory lives - and all this in a subshell, so we don't affect
# $PWD
GAMEROOT=$(cd "${0%/*}" && echo $PWD)
#determine platform
UNAME=`uname`
if [ "$UNAME" == "Darwin" ]; then
# Workaround OS X El Capitan 10.11 System Integrity Protection (SIP) which does not allow
# DYLD_INSERT_LIBRARIES to be set for system processes.
if [ "$STEAM_DYLD_INSERT_LIBRARIES" != "" ] && [ "$DYLD_INSERT_LIBRARIES" == "" ]; then
export DYLD_INSERT_LIBRARIES="$STEAM_DYLD_INSERT_LIBRARIES"
fi
# prepend our lib path to LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=${GAMEROOT}:$DYLD_LIBRARY_PATH
elif [ "$UNAME" == "Linux" ]; then
# prepend our lib path to LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${GAMEROOT}:$LD_LIBRARY_PATH
fi
if [ -z $GAMEEXE ]; then
if [ "$UNAME" == "Darwin" ]; then
GAMEEXE=hl_osx
elif [ "$UNAME" == "Linux" ]; then
GAMEEXE=hl_linux
fi
fi
ulimit -n 2048
# and launch the game
cd "$GAMEROOT"
STATUS=42
while [ $STATUS -eq 42 ]; do
${DEBUGGER} "${GAMEROOT}"/${GAMEEXE} $@
STATUS=$?
done
exit $STATUS
powerkitten@blaze-pc:~/Desktop/depotdownloader-2.3.0-hotfix1/halflife$ osh hl.sh
GAMEROOT=$(cd "${0%/*}" && echo $PWD)
^
hl.sh:9: cd '/home/powerkitten/Desktop/depotdownloader-2.3.0-hotfix1/halflife/hl.sh': Not a directory
ulimit -n 2048
^~~~~~
hl.sh:34: Can't execute 'ulimit': No such file or directory
${DEBUGGER} "${GAMEROOT}"/${GAMEEXE} $@
^
hl.sh:41: Can't execute '/hl_linux': No such file or directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment