Skip to content

Instantly share code, notes, and snippets.

@Ch00k
Last active December 20, 2015 21:59
Show Gist options
  • Select an option

  • Save Ch00k/6201689 to your computer and use it in GitHub Desktop.

Select an option

Save Ch00k/6201689 to your computer and use it in GitHub Desktop.
gnu_utils=( awk find sed make tail )
case "$(uname)" in
(SunOS)
[[ -x /usr/gnu/bin/grep ]] ||
rvm_error "ERROR: Missing '/usr/gnu/bin/grep', make sure it is installed before using RVM!"
__rvm_grep()
{
GREP_OPTIONS="" /usr/gnu/bin/grep "$@" || return $?;
}
for gnu_util in "${gnu_utils[@]}"
do
[[ -x /usr/gnu/bin/$gnu_util ]] ||
rvm_error "ERROR: Missing '/usr/gnu/bin/$gnu_util', make sure it is installed before using RVM!"
eval "__rvm_$gnu_util() { /usr/gnu/bin/$gnu_util \"\$@\" || return \$?; }"
done
;;
(*)
__rvm_grep()
{
GREP_OPTIONS="" \grep "$@" || return $?
}
for gnu_util in "${gnu_utils[@]}"
do
eval "__rvm_$gnu_util() { \\$gnu_util \"\$@\" || return \$?; }"
done
;;
esac
unset gnu_util gnu_utils
@mpapis
Copy link
Copy Markdown

mpapis commented Aug 11, 2013

the GREP_OPTIONS="" have to be on the same line with command, if it is on separate command then it is changed for the current subshell - which could influence other tools / scripts if any used:

 GREP_OPTIONS="" /usr/gnu/bin/grep "$@" || return $?;

and:

 GREP_OPTIONS="" \grep "$@" || return $?;

@mpapis
Copy link
Copy Markdown

mpapis commented Aug 11, 2013

one more, in this:

for gnu_util in "${gnu_utils[@]}"
do
  eval "__rvm_$gnu_util() { \\$gnu_util \"\$@\" || return \$? }"
done

semicolon is missing:

for gnu_util in "${gnu_utils[@]}"
do
  eval "__rvm_$gnu_util() { \\$gnu_util \"\$@\" || return \$?; }"
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment