Skip to content

Instantly share code, notes, and snippets.

@flibitijibibo
Created April 11, 2013 16:58
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save flibitijibibo/5365145 to your computer and use it in GitHub Desktop.
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/.
#!/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
@jawnsy
Copy link

jawnsy commented Dec 31, 2018

Wouldn't this technique result in an intermediate shell process hanging around until the program exits? Something like:

bash
`- GameName.sh
    `- gamename.x86_64

Are signals handled correctly? Would it be better to use exec ./x86_64/gamename.x86_64 to replace the running shell process?

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