Skip to content
This repository
Newer
Older
100755 47 lines (39 sloc) 0.951 kb
22b433a3 »
2011-08-29 Don't assume that bash is in /bin
1 #!/usr/bin/env bash
2
3 set -e
4 set -u
fccc6851 »
2011-06-21 Initial open-source release
5
6 # Include in your scripts to detect the host platform and have appropriate
7 # aliases set for some commands (eg use the GNU versions on a mac)
8 # Example:
9 # $ . platform_helper.sh
10 # $ if [ "$IS_LINUX" ]; then echo "I am Linux"; fi
11
12 IS_LINUX=""
13 IS_MAC=""
14 IS_WINDOWS=""
15
16 case $(uname) in
17 CYGWIN*) IS_WINDOWS=1;;
18 Darwin*) IS_MAC=1;;
7de4ee06 »
2011-09-12 New platform: `FreeBSD'
19 Linux*|GNU/kFreeBSD) IS_LINUX=1;;
20 FreeBSD) IS_FREEBSD=1;;
fccc6851 »
2011-06-21 Initial open-source release
21 *)
22 echo "Error: could not detect OS. Defaulting to Linux" >&2
23 IS_LINUX=1
24 esac
25
26 # Defining aliases for a few commands
27
28 if [ -n "$IS_MAC" ]; then
29 SED=gsed
30 TAIL=gtail
31 MKTEMP=gmktemp
32 SORT=gsort
33 READLINK=greadlink
34 else
35 SED=sed
36 TAIL=tail
37 MKTEMP=mktemp
38 SORT=sort
39 READLINK=readlink
40 fi
41
42 tail() { command "$TAIL" "$@"; }
43 mktemp() { command "$MKTEMP" "$@"; }
44 sed() { command "$SED" "$@"; }
45 sort() { command "$SORT" "$@"; }
46 readlink() { command "$READLINK" "$@"; }
Something went wrong with that request. Please try again.