Created
April 11, 2013 16:58
-
-
Save flibitijibibo/5365145 to your computer and use it in GitHub Desktop.
A variant of this launcher ships in every game I've worked on. While the filename here is GameName.sh, I do not use the .sh extension. Just `chmod +x` this and put your OSX bins in osx/, Linux 32-bit bins in x86/, and Linux 64-bit bins in x86_64/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# GameName Shell Script | |
# Written by Ethan "flibitijibibo" Lee | |
# Move to script's directory | |
cd "`dirname "$0"`" | |
# Get the kernel/architecture information | |
UNAME=`uname` | |
ARCH=`uname -m` | |
# Set the libpath and pick the proper binary | |
if [ "$UNAME" == "Darwin" ]; then | |
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:./osx/ | |
./osx/gamename.osx | |
elif [ "$UNAME" == "Linux" ]; then | |
if [ "$ARCH" == "x86_64" ]; then | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./x86_64/ | |
./x86_64/gamename.x86_64 | |
else | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./x86/ | |
./x86/gamename.x86 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wouldn't this technique result in an intermediate shell process hanging around until the program exits? Something like:
Are signals handled correctly? Would it be better to use
exec ./x86_64/gamename.x86_64
to replace the running shell process?