Created
August 24, 2013 17:39
-
-
Save Ch00k/6329401 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gnu_utils=( awk find sed make tail date) | |
| case "$(uname)" in | |
| (SunOS) | |
| case "$(uname -v)" in | |
| (*joyent*) | |
| gnu_tools_path=/opt/local/bin | |
| gnu_modifier="" | |
| ;; | |
| (*) | |
| case "$(uname -r)" in | |
| (5.10) | |
| gnu_tools_path=/opt/csw/bin | |
| gnu_modifier="g" | |
| ;; | |
| (5.11) | |
| gnu_tools_path=/usr/gnu/bin | |
| gnu_modifier="" | |
| ;; | |
| esac | |
| ;; | |
| esac | |
| if | |
| [[ -x $gnu_tools_path/${gnu_modifier}grep ]] | |
| then | |
| eval "__rvm_grep() { GREP_OPTIONS=\"\" $gnu_tools_path/${gnu_modifier}grep \"\$@\" || return \$?; }" | |
| else | |
| rvm_error "ERROR: Missing GNU grep. Make sure it is installed in $gnu_tools_path/${gnu_modifier}grep before using RVM!" | |
| exit 1 | |
| fi | |
| if | |
| [[ -x $gnu_tools_path/${gnu_modifier}which ]] | |
| then | |
| eval "__rvm_which() { $gnu_tools_path/${gnu_modifier}which \"\$@\" || return \$?; }" | |
| else | |
| rvm_error "ERROR: Missing GNU grep. Make sure it is installed in $gnu_tools_path/${gnu_modifier}grep before using RVM!" | |
| exit 1 | |
| fi | |
| for gnu_util in "${gnu_utils[@]}" | |
| do | |
| if | |
| [[ -x $gnu_tools_path/$gnu_modifier$gnu_util ]] | |
| then | |
| eval "__rvm_$gnu_util() { $gnu_tools_path/$gnu_modifier$gnu_util \"\$@\" || return \$?; }" | |
| else | |
| rvm_error "ERROR: Missing GNU $gnu_util. Make sure it is installed in $gnu_tools_path/$gnu_modifier$gnu_util before using RVM!" | |
| exit 1 | |
| fi | |
| done | |
| ;; | |
| (*) | |
| __rvm_grep() | |
| { | |
| GREP_OPTIONS="" \grep "$@" || return $? | |
| } | |
| __rvm_which() | |
| { | |
| if command which --skip-alias --skip-functions which >/dev/null 2>&1 | |
| then command which --skip-alias --skip-functions "$@" | |
| elif command whence whence >/dev/null 2>&1 | |
| then command whence -p "$@" | |
| elif command which which >/dev/null 2>&1 | |
| then command which "$@" | |
| elif which which >/dev/null 2>&1 | |
| then which "$@" | |
| else return 1 | |
| fi | |
| } | |
| for gnu_util in "${gnu_utils[@]}" | |
| do | |
| eval "__rvm_$gnu_util() { \\$gnu_util \"\$@\" || return \$?; }" | |
| done | |
| ;; | |
| esac | |
| unset gnu_tools_path gnu_modifier gnu_util gnu_utils |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment