Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 43 lines (36 sloc) 0.891 kb
fccc685 Initial open-source release
MLstate authored
1 #!/bin/bash -eu
2
3 # Include in your scripts to detect the host platform and have appropriate
4 # aliases set for some commands (eg use the GNU versions on a mac)
5 # Example:
6 # $ . platform_helper.sh
7 # $ if [ "$IS_LINUX" ]; then echo "I am Linux"; fi
8
9 IS_LINUX=""
10 IS_MAC=""
11 IS_WINDOWS=""
12
13 case $(uname) in
14 CYGWIN*) IS_WINDOWS=1;;
15 Darwin*) IS_MAC=1;;
16 Linux*) IS_LINUX=1;;
17 *)
18 echo "Error: could not detect OS. Defaulting to Linux" >&2
19 IS_LINUX=1
20 esac
21
22 # Defining aliases for a few commands
23
24 if [ -n "$IS_MAC" ]; then
25 SED=gsed
26 TAIL=gtail
27 MKTEMP=gmktemp
28 SORT=gsort
29 READLINK=greadlink
30 else
31 SED=sed
32 TAIL=tail
33 MKTEMP=mktemp
34 SORT=sort
35 READLINK=readlink
36 fi
37
38 tail() { command "$TAIL" "$@"; }
39 mktemp() { command "$MKTEMP" "$@"; }
40 sed() { command "$SED" "$@"; }
41 sort() { command "$SORT" "$@"; }
42 readlink() { command "$READLINK" "$@"; }
Something went wrong with that request. Please try again.