Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 44 lines (37 sloc) 0.936 kb
22b433a Don't assume that bash is in /bin
Frédéric Perrin authored
1 #!/usr/bin/env bash
2
fccc685 Initial open-source release
MLstate authored
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;;
7de4ee0 New platform: `FreeBSD'
Frédéric Perrin authored
16 Linux*|GNU/kFreeBSD) IS_LINUX=1;;
17 FreeBSD) IS_FREEBSD=1;;
fccc685 Initial open-source release
MLstate authored
18 *)
19 echo "Error: could not detect OS. Defaulting to Linux" >&2
20 IS_LINUX=1
21 esac
22
23 # Defining aliases for a few commands
24
25 if [ -n "$IS_MAC" ]; then
26 SED=gsed
27 TAIL=gtail
28 MKTEMP=gmktemp
29 SORT=gsort
30 READLINK=greadlink
31 else
32 SED=sed
33 TAIL=tail
34 MKTEMP=mktemp
35 SORT=sort
36 READLINK=readlink
37 fi
38
39 tail() { command "$TAIL" "$@"; }
40 mktemp() { command "$MKTEMP" "$@"; }
41 sed() { command "$SED" "$@"; }
42 sort() { command "$SORT" "$@"; }
43 readlink() { command "$READLINK" "$@"; }
Something went wrong with that request. Please try again.