Advertisement
wonderbreadz

Portal2.sh

Apr 19th, 2011
828
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.10 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # figure out the absolute path to the script being run a bit
  4. # non-obvious, the ${0%/*} pulls the path out of $0, cd's into the
  5. # specified directory, then uses $PWD to figure out where that
  6. # directory lives - and all this in a subshell, so we don't affect
  7. # $PWD
  8.  
  9. GAMEROOT=$(cd "${0%/*}" && echo $PWD)
  10.  
  11. #determine platform
  12. UNAME=`uname`
  13. if [ "$UNAME" == "Darwin" ]; then
  14.    # prepend our lib path to LD_LIBRARY_PATH
  15.    export DYLD_LIBRARY_PATH="${GAMEROOT}"/bin:$DYLD_LIBRARY_PATH
  16. elif [ "$UNAME" == "Linux" ]; then
  17.    # prepend our lib path to LD_LIBRARY_PATH
  18.    export LD_LIBRARY_PATH="${GAMEROOT}"/bin:$LD_LIBRARY_PATH
  19. fi
  20.  
  21. if [ -z $GAMEEXE ]; then
  22.     if [ "$UNAME" == "Darwin" ]; then
  23.         GAMEEXE=portal2_osx
  24.     fi
  25. fi
  26.  
  27. ulimit -n 2048
  28.  
  29. # and launch the game
  30. cd "$GAMEROOT"
  31.  
  32. STATUS=42
  33. while [ $STATUS -eq 42 ]; do
  34.     if [ "${DEBUGGER}" == "gdb" ]; then
  35.         ARGSFILE=$(mktemp $USER.portal2.gdb.XXXX)
  36.         echo run $@ > "$ARGSFILE"
  37.         ${DEBUGGER} "${GAMEROOT}"/${GAMEEXE} -x "$ARGSFILE"
  38.         rm "$ARGSFILE"
  39.     else
  40.         ${DEBUGGER} "${GAMEROOT}"/${GAMEEXE} "$@"
  41.     fi
  42.     STATUS=$?
  43. done
  44. exit $STATUS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement