#!/usr/bin/env bash 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_OPTIONS="" \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 # duplication marker jdgkjnfnkjdngjkfnd4fd export rvm_path if [[ -z "${rvm_path:-}" ]] then if [[ -d "${0%/bin/rvm-shell}" ]] then rvm_path="$( \cd "${0%/bin/rvm-shell}">/dev/null; pwd )" elif (( 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 rvm_path="${rvm_path%%*(/)}" # remove trailing slashes case $0 in (*-rvm-env) selected_shell=${0%-rvm-env} ;; (*) selected_shell=bash ;; esac selected_shell="$(basename "${selected_shell}")" if [[ -n "$1" && ! -f "$1" && -n "$(echo "$1" | GREP_OPTIONS="" \grep -v '^-')" ]] then rvm_shell_ruby_string="$1" shift elif [[ "$1" == "--path" ]] && [[ -d "$2" || "$2" == "/"* ]] then if [[ -d "$2" ]] then cd $2 else rvm_shell_ruby_string="default" fi shift 2 fi true ${rvm_scripts_path:="$rvm_path/scripts"} export rvm_scripts_path if [[ -n "$rvm_path" && -f "$rvm_scripts_path/rvm" ]] then source "$rvm_scripts_path/rvm" typeset -f rvm >/dev/null 2>&1 || { echo "RVM not loaded, aborting." >&2 exit 1 } # Setup as expected. if [[ -n "$rvm_shell_ruby_string" ]] then unset GEM_HOME # disable GEM_HOME mismatch check when using ruby __rvm_conditionally_do_with_env __rvm_use "$rvm_shell_ruby_string" || { __status=$? echo "Error: RVM was unable to use '$rvm_shell_ruby_string'" 1>&2 exit ${__status} } else __rvm_conditionally_do_with_env __rvm_rvmrc_tools load . >/dev/null 2>&1 fi fi exec ${selected_shell} "$@"