Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created July 30, 2014 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Constellation/e213fd9b068559b670d7 to your computer and use it in GitHub Desktop.
Save Constellation/e213fd9b068559b670d7 to your computer and use it in GitHub Desktop.
#!/bin/sh
OS="$(uname -s)"
ARCH="$(uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ -e s/amd64/x86/ \
-e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
-e s/sh[234].*/sh/ -e s/aarch64.*/arm64/)"
BIT="$(getconf LONG_BIT)"
case "$OS" in
Linux)
TARGET="$(readlink -f "${0}")"
;;
*)
TARGET="$(readlink "${0}")"
;;
esac
COMMAND="${TARGET}-${OS}-${ARCH}-${BIT}"
if [ -e $COMMAND ]; then
exec $COMMAND
else
echo "Command ${COMMAND} not found."
echo "Unsupported architecture ${OS} ${ARCH} ${BIT}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment