Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.