Created
January 15, 2012 09:04
-
-
Save mpapis/1615150 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
| #!/usr/bin/env bash | |
| # put this in /usr/bin/ruby-env and do not forget to chmod +x it | |
| # then jsut shebang: #!/usr/bin/ruby-env 1.9.3 | |
| export HOME="${HOME%%+(\/)}" # Remove trailing slashes if they exist on HOME | |
| if (( ${rvm_ignore_rvmrc:=0} == 0 )) | |
| then | |
| for rvmrc in /etc/rvmrc "$HOME/.rvmrc" | |
| do | |
| if [[ -f "$rvmrc" ]] | |
| then | |
| if \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1 | |
| then | |
| printf "%b" "\nError: $rvmrc is for rvm settings only.\nrvm CLI may NOT be called from within $rvmrc. \nSkipping the loading of $rvmrc" | |
| return 1 | |
| else | |
| source "$rvmrc" | |
| fi | |
| fi | |
| done | |
| fi | |
| export rvm_path | |
| if [[ -z "${rvm_path:-}" ]] | |
| then | |
| if (( UID == 0 )) && [[ -d "/usr/local/rvm" ]] | |
| then rvm_path="/usr/local/rvm" | |
| elif [[ -d "${HOME}/.rvm" ]] | |
| then rvm_path="${HOME}/.rvm" | |
| elif [[ -d "/usr/local/rvm" ]] | |
| then rvm_path="/usr/local/rvm" | |
| else echo "Can't find rvm install!" 1>&2 ; exit 1 | |
| fi | |
| fi | |
| true ${rvm_scripts_path:="$rvm_path/scripts"} | |
| __rvm_shell_lookup_script() | |
| { | |
| local relative_scripts_dir | |
| relative_scripts_dir="$(dirname -- "$(dirname -- "$0")")/scripts" #" | |
| for directory in "$rvm_scripts_path" "$HOME/.rvm/scripts" "/usr/local/rvm/scripts" "$relative_scripts_dir"; do | |
| if [[ -d "$directory" && -s "$directory/rvm" ]]; then | |
| echo "$directory/rvm" | |
| return | |
| fi | |
| done | |
| } | |
| if [[ -n "$1" && ! -f "$1" && -n "$(echo "$1" | \grep -v '^-')" ]]; then | |
| rvm_shell_ruby_string="$1" | |
| shift | |
| fi | |
| rvm_shell_rvm_path="$(__rvm_shell_lookup_script)" | |
| if [[ -n "$rvm_shell_rvm_path" ]]; then | |
| source "$rvm_shell_rvm_path" | |
| # Setup as expected. | |
| if [[ -n "$rvm_shell_ruby_string" ]]; then | |
| rvm "$rvm_shell_ruby_string" | |
| if [[ "$?" -gt 0 ]]; then | |
| echo "Error: RVM was unable to use '$rvm_shell_ruby_string'" 1>&2 | |
| exit 1 | |
| fi | |
| else | |
| rvm rvmrc load >/dev/null 2>&1 | |
| fi | |
| fi | |
| exec ruby "$@" |
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
| #!/usr/bin/ruby-env 1.9.3 | |
| puts ' RUBY_VERSION= ' + RUBY_VERSION.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment