Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 43 lines (36 sloc) 0.891 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#!/bin/bash -eu

# Include in your scripts to detect the host platform and have appropriate
# aliases set for some commands (eg use the GNU versions on a mac)
# Example:
# $ . platform_helper.sh
# $ if [ "$IS_LINUX" ]; then echo "I am Linux"; fi

IS_LINUX=""
IS_MAC=""
IS_WINDOWS=""

case $(uname) in
    CYGWIN*) IS_WINDOWS=1;;
    Darwin*) IS_MAC=1;;
    Linux*) IS_LINUX=1;;
    *)
        echo "Error: could not detect OS. Defaulting to Linux" >&2
        IS_LINUX=1
esac

# Defining aliases for a few commands

if [ -n "$IS_MAC" ]; then
SED=gsed
    TAIL=gtail
    MKTEMP=gmktemp
    SORT=gsort
    READLINK=greadlink
else
SED=sed
    TAIL=tail
    MKTEMP=mktemp
    SORT=sort
    READLINK=readlink
fi

tail() { command "$TAIL" "$@"; }
mktemp() { command "$MKTEMP" "$@"; }
sed() { command "$SED" "$@"; }
sort() { command "$SORT" "$@"; }
readlink() { command "$READLINK" "$@"; }
Something went wrong with that request. Please try again.