trigger event of Apple_PubSub_Socket_Render=/tmp/launch-qzLCZb/Render
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_REMATCH=([0]=" cd ")
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="51" [3]="1" [4]="release" [5]="x86_64-apple-darwin13")
BASH_VERSION='3.2.51(1)-release'
COLUMNS=169
DIRSTACK=()
DISPLAY=/tmp/launch-RUMv62/org.macosforge.xquartz:0
EUID=501
GEM_HOME=/Users/boris/.rvm/gems/ruby-1.9.3-p448
GEM_PATH=/Users/boris/.rvm/gems/ruby-1.9.3-p448:/Users/boris/.rvm/gems/ruby-1.9.3-p448@global
GROUPS=()
HISTFILE=/Users/boris/.bash_history
HISTFILESIZE=500
HISTSIZE=500
HOME=/Users/boris
HOSTNAME=Boriss-MacBook-Pro.local
HOSTTYPE=x86_64
IFS=$' \t\n'
IRBRC=/Users/boris/.rvm/rubies/ruby-1.9.3-p448/.irbrc
LANG=en_US.UTF-8
LINES=24
LOGNAME=boris
MACHTYPE=x86_64-apple-darwin13
MAILCHECK=60
MY_RUBY_HOME=/Users/boris/.rvm/rubies/ruby-1.9.3-p448
OLDPWD=/Users/boris/Sites/date
OPTERR=1
OPTIND=1
OSTYPE=darwin13
PATH=/Users/boris/.rvm/gems/ruby-1.9.3-p448/bin:/Users/boris/.rvm/gems/ruby-1.9.3-p448@global/bin:/Users/boris/.rvm/rubies/ruby-1.9.3-p448/bin:/Users/boris/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
PIPESTATUS=([0]="0")
PPID=9176
PROMPT_COMMAND='update_terminal_cwd; '
PS1='\h:\W \u\$ '
PS2='> '
PS4='+ '
PWD=/Users/boris/Sites/github/umodel
RUBY_VERSION=ruby-1.9.3-p448
SECURITYSESSIONID=186a5
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=1
SSH_AUTH_SOCK=/tmp/launch-G1PIKk/Listeners
TERM=xterm-256color
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=326
TERM_SESSION_ID=085551AD-38DD-4C0F-AEB7-ECDD8728BFE0
TMPDIR=/var/folders/8y/q7cvb9ds509d52cfnhg_6bbh0000gn/T/
UID=501
USER=boris
_=status
__CF_USER_TEXT_ENCODING=0x1F5:0:0
__CHECKFIX1436934=1
old_rvm_debug_flag=0
old_rvm_verbose_flag=0
rvm_bin_path=/Users/boris/.rvm/bin
rvm_ignore_rvmrc=0
rvm_path=/Users/boris/.rvm
rvm_prefix=/Users/boris
rvm_rubygems_path=/Users/boris/.rvm/rubygems
rvm_version='1.21.14 (stable)'
rvmrc=/Users/boris/.rvmrc
script=override_gem
__function_on_stack ()
{
    __rvm_string_includes "${FUNCNAME[*]}" "$@" || return $?
}
__function_unset ()
{
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        unset -f "$1";
    else
        unset "$1";
    fi
}
__list_remote_all_for ()
{
    {
        __list_remote_rubies_for "$1";
        __list_remote_rbx_for "$1";
        __list_remote_jruby_for "$1"
    } | sort -u
}
__list_remote_jruby_for ()
{
    typeset rvm_ruby_url;
    rvm_ruby_url="$1";
    __rvm_curl -s "http://jruby.org.s3.amazonaws.com/?prefix=downloads/&delimiter=/" | GREP_OPTIONS="" \grep -oE "<Key>[^<]*</Key>" | GREP_OPTIONS="" \grep -o '[[:digit:]][^_]*' | awk '{print "http://jruby.org.s3.amazonaws.com/downloads/"$1"/jruby-bin-"$1".tar.gz"}' | GREP_OPTIONS="" \grep "${rvm_ruby_url}"
}
__list_remote_rbx_for ()
{
    __rvm_curl -s http://binaries.rubini.us/index.txt | GREP_OPTIONS="" \grep -E "$1.*\.tar\.bz2$"
}
__list_remote_rubies_for ()
{
    typeset rvm_ruby_url;
    rvm_ruby_url="$1";
    awk '/'"${rvm_ruby_url//\//\/}"'/{print}' < $rvm_path/config/remote;
    if [[ -f $rvm_user_path/remote ]]; then
        awk '/'"${rvm_ruby_url//\//\/}"'/{print}' < $rvm_user_path/remote;
    fi
}
__rvm_add_to_path ()
{
    export PATH;
    if (( $# != 2 )) || [[ -z "$2" ]]; then
        rvm_error "__rvm_add_to_path requires two parameters";
        return 1;
    fi;
    __rvm_remove_from_path "$2";
    case "$1" in
        prepend)
            PATH="$2:$PATH"
        ;;
        append)
            PATH="$PATH:$2"
        ;;
    esac;
    if [[ -n "${rvm_user_path_prefix:-}" ]]; then
        __rvm_remove_from_path "${rvm_user_path_prefix}";
        PATH="${rvm_user_path_prefix}:$PATH";
    fi;
    builtin hash -r
}
__rvm_after_cd ()
{
    typeset rvm_hook;
    rvm_hook="after_cd";
    if [[ -n "${rvm_scripts_path:-}" || -n "${rvm_path:-}" ]]; then
        source "${rvm_scripts_path:-$rvm_path/scripts}/hook";
    fi
}
__rvm_array_add_or_update ()
{
    typeset _array_name _variable _separator _value _local_value;
    typeset -a _array_value_old _array_value_new;
    _array_name="$1";
    _variable="$2";
    _separator="$3";
    _value="${4##${_separator}}";
    _array_value_new=();
    eval "_array_value_old=( \"\${${_array_name}[@]}\" )";
    case " ${_array_value_old[*]} " in
        *[[:space:]]${_variable}*)
            for _local_value in "${_array_value_old[@]}";
            do
                case "${_local_value}" in
                    ${_variable}*)
                        _array_value_new+=("${_local_value}${_separator}${_value}")
                    ;;
                    *)
                        _array_value_new+=("${_local_value}")
                    ;;
                esac;
            done
        ;;
        *)
            _array_value_new=("${_array_value_old[@]}" "${_variable}${_value}")
        ;;
    esac;
    eval "${_array_name}=( \"\${_array_value_new[@]}\" )"
}
__rvm_array_contains ()
{
    typeset _search _iterator;
    _search="$1";
    shift;
    for _iterator in "$@";
    do
        case "${_iterator}" in
            ${_search})
                return 0
            ;;
        esac;
    done;
    return 1
}
__rvm_array_prepend_or_ignore ()
{
    typeset _array_name _variable _separator _value _local_value;
    typeset -a _array_value_old _array_value_new;
    _array_name="$1";
    _variable="$2";
    _separator="$3";
    _value="$4";
    _array_value_new=();
    eval "_array_value_old=( \"\${${_array_name}[@]}\" )";
    case " ${_array_value_old[*]} " in
        *[[:space:]]${_variable}*)
            for _local_value in "${_array_value_old[@]}";
            do
                case "${_local_value}" in
                    ${_variable}*)
                        rvm_debug "__rvm_array_prepend_or_ignore ${_array_name} ${_variable}\"${_value}${_separator}${_local_value#${_variable}}\"";
                        _array_value_new+=("${_variable}${_value}${_separator}${_local_value#${_variable}}")
                    ;;
                    *)
                        _array_value_new+=("${_local_value}")
                    ;;
                esac;
            done;
            eval "${_array_name}=( \"\${_array_value_new[@]}\" )"
        ;;
    esac
}
__rvm_ask_for ()
{
    typeset response;
    rvm_warn "$1";
    printf "%b" "(anything other than '$2' will cancel) > ";
    if read response && [[ "$2" == "$response" ]]; then
        return 0;
    else
        return 1;
    fi
}
__rvm_ask_to_trust ()
{
    typeset trusted value anykey _rvmrc;
    _rvmrc="${1}";
    if [[ ! -t 0 || -n "$MC_SID" ]] || (( ${rvm_promptless:=0} == 1 )); then
        return 2;
    fi;
    __rvm_table "NOTICE"  <<-TEXT
RVM has encountered a new or modified $(basename "${_rvmrc}") file in the current directory, this is a shell script and therefore may contain any shell commands.

Examine the contents of this file carefully to be sure the contents are safe before trusting it!
Do you wish to trust '${_rvmrc}'?
Choose v[iew] below to view the contents
TEXT

    trusted=0;
    while (( ! trusted )); do
        printf "%b" 'y[es], n[o], v[iew], c[ancel]> ';
        builtin read response;
        value="$(echo -n "${response}" | \tr '[[:upper:]]' '[[:lower:]]' | __rvm_strip)";
        case "${value:-n}" in
            v | view)
                __rvm_display_rvmrc
            ;;
            y | yes)
                trusted=1
            ;;
            n | no)
                break
            ;;
            c | cancel)
                return 1
            ;;
        esac;
    done;
    if (( trusted )); then
        __rvm_trust_rvmrc "$1";
        return 0;
    else
        __rvm_untrust_rvmrc "$1";
        return 1;
    fi
}
__rvm_become ()
{
    typeset string rvm_rvmrc_flag;
    string="$1";
    rvm_rvmrc_flag=0;
    [[ -n "$string" ]] && {
        rvm_ruby_string="$string";
        rvm_gemset_name=""
    };
    __rvm_use > /dev/null || return $?;
    rvm_ruby_string="${rvm_ruby_string}${rvm_gemset_name:+${rvm_gemset_separator:-'@'}}${rvm_gemset_name:-}";
    return 0
}
__rvm_calculate_remote_file ()
{
    rvm_remote_server_url="$( __rvm_db "rvm_remote_server_url${3:-}" )";
    [[ -n "$rvm_remote_server_url" ]] || {
        rvm_debug "rvm_remote_server_url${3:-} not found";
        return $1
    };
    __rvm_system_path "" "${3:-}";
    __rvm_ruby_package_file "${4:-}";
    __remote_file="${rvm_remote_server_url}/${rvm_remote_server_path}${rvm_ruby_package_file}"
}
__rvm_call_with_restored_umask ()
{
    rvm_umask="$(umask)";
    if [[ -n "${rvm_stored_umask:-}" ]]; then
        umask ${rvm_stored_umask};
    fi;
    "$@";
    umask "${rvm_umask}";
    unset rvm_umask
}
__rvm_cd ()
{
    typeset old_cdpath ret;
    ret=0;
    old_cdpath="${CDPATH}";
    CDPATH=".";
    chpwd_functions="" builtin cd "$@" || ret=$?;
    CDPATH="${old_cdpath}";
    return $ret
}
__rvm_cd_functions_set ()
{
    __rvm_do_with_env_before;
    __rvm_project_rvmrc && __rvm_after_cd || true;
    __rvm_do_with_env_after;
    return 0
}
__rvm_check_pipestatus ()
{
    for __iterator in "$@";
    do
        case "${__iterator}" in
            "")
                true
            ;;
            0)
                true
            ;;
            *)
                return ${__iterator}
            ;;
        esac;
    done;
    return 0
}
__rvm_check_rvmrc_trustworthiness ()
{
    (( ${rvm_trust_rvmrcs_flag:-0} == 0 )) || return 0;
    [[ -n "$1" ]] || return 1;
    typeset _first _second saveIFS;
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        _first=1;
    else
        _first=0;
    fi;
    _second=$(( _first + 1 ));
    saveIFS="$IFS";
    IFS=';';
    typeset -a trust;
    trust=($( __rvm_rvmrc_stored_trust "$1" ));
    IFS="$saveIFS";
    if [[ "${trust[${_second}]:-'#'}" == "$(__rvm_checksum_for_contents "$1")" ]]; then
        [[ "${trust[${_first}]}" == '1' ]] || return $?;
    else
        __rvm_ask_to_trust "$1" || return $?;
    fi;
    true
}
__rvm_checksum_all ()
{
    [[ -n "${_checksum_md5:-}" && -n "${_checksum_sha512:-}" ]]
}
__rvm_checksum_any ()
{
    [[ -n "${_checksum_md5:-}" || -n "${_checksum_sha512:-}" ]]
}
__rvm_checksum_calculate_file ()
{
    _checksum_md5="$(    __rvm_md5_calculate      "${1:-}" )";
    _checksum_sha512="$( __rvm_sha__calculate 512 "${1:-}" )"
}
__rvm_checksum_for_contents ()
{
    typeset __sum;
    __sum=$(  echo "$1" | \cat - "$1" | __rvm_md5_for_contents   ) || {
        rvm_error "Neither md5 nor md5sum were found in the PATH";
        return 1
    };
    __sum+=$( echo "$1" | \cat - "$1" | __rvm_sha256_for_contents ) || {
        rvm_error "Neither sha256sum nor shasum found in the PATH";
        return 1
    };
    echo ${__sum}
}
__rvm_checksum_none ()
{
    [[ -z "${_checksum_md5:-}" && -z "${_checksum_sha512:-}" ]]
}
__rvm_checksum_read ()
{
    __rvm_checksum_none || return 0;
    typeset _type _value _name;
    typeset -a _list;
    list=();
    for _name in "$@";
    do
        list+=("$_name");
        if [[ "$_name" =~ "?" ]]; then
            list+=("${_name%\?*}");
        fi;
    done;
    for _name in "${list[@]}";
    do
        _checksum_md5="$(      "$rvm_scripts_path/db" "$rvm_path/config/md5"    "$_name" | head -n 1 )";
        [[ -n "${_checksum_md5:-}" ]] || _checksum_md5="$(    "$rvm_scripts_path/db" "$rvm_user_path/md5"      "$_name" | head -n 1 )";
        _checksum_sha512="$(   "$rvm_scripts_path/db" "$rvm_path/config/sha512" "$_name" | head -n 1 )";
        [[ -n "${_checksum_sha512:-}" ]] || _checksum_sha512="$( "$rvm_scripts_path/db" "$rvm_user_path/sha512"   "$_name" | head -n 1 )";
        __rvm_checksum_none || return 0;
    done;
    return 1
}
__rvm_checksum_validate_file ()
{
    __rvm_checksum_any || return 1;
    if [[ -n "${_checksum_md5:-}" ]]; then
        [[ "$(__rvm_md5_calculate "${1:-}")" == "${_checksum_md5:-}" ]] || return 2;
    fi;
    if [[ -n "${_checksum_sha512:-}" ]]; then
        [[ "$(__rvm_sha__calculate 512 "${1:-}")" == "${_checksum_sha512:-}" ]] || return 3;
    fi;
    return 0
}
__rvm_checksum_write ()
{
    [[ -n "${1:-}" ]] || return 1;
    __rvm_checksum_any || return 1;
    [[ -z "${_checksum_md5:-}" ]] || "$rvm_scripts_path/db" "$rvm_user_path/md5" "${1:-}" "${_checksum_md5:-}";
    [[ -z "${_checksum_sha512:-}" ]] || "$rvm_scripts_path/db" "$rvm_user_path/sha512" "${1:-}" "${_checksum_sha512:-}";
    return 0
}
__rvm_clean_path ()
{
    export PATH;
    typeset IFS _iterator_path;
    typeset -a _old_path _new_path;
    IFS=:;
    _old_path=();
    _new_path=();
    __rvm_custom_separated_array _old_path : "${PATH}";
    for _iterator_path in "${_old_path[@]}";
    do
        [[ ":${_new_path[*]}:" =~ :${_iterator_path}: ]] || _new_path+=("${_iterator_path}");
    done;
    PATH="${_new_path[*]}";
    builtin hash -r
}
__rvm_cleanse_variables ()
{
    __rvm_unset_ruby_variables;
    if [[ ${rvm_sticky_flag:-0} -eq 1 ]]; then
        export rvm_gemset_name;
    else
        unset rvm_gemset_name;
    fi;
    unset rvm_configure_flags rvm_patch_names rvm_make_flags;
    unset rvm_env_string rvm_ruby_string rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_bin_flag rvm_import_flag rvm_export_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_sticky_flag rvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag rvm_docs_flag rvm_dump_environment_flag rvm_ruby_alias rvm_static_flag rvm_archive_extension rvm_hook rvm_ruby_name rvm_remote_flag;
    __rvm_load_rvmrc
}
__rvm_cleanup_tmp ()
{
    if [[ -d "${rvm_tmp_path}/" ]]; then
        case "${rvm_tmp_path%\/}" in
            *tmp)
                __rvm_rm_rf "${rvm_tmp_path}/${1:-$$}*"
            ;;
        esac;
    fi;
    return 0
}
__rvm_conditionally_add_bin_path ()
{
    [[ ":${PATH}:" =~ ":${rvm_bin_path}:" ]] || {
        case "${rvm_ruby_string:-"system"}" in
            system)
                PATH="$PATH:${rvm_bin_path}"
            ;;
            *)
                PATH="${rvm_bin_path}:$PATH"
            ;;
        esac;
        builtin hash -r
    }
}
__rvm_conditionally_do_with_env ()
{
    if (( __rvm_env_loaded > 0 )); then
        "$@";
    else
        __rvm_do_with_env "$@";
    fi
}
__rvm_curl ()
{
    ( __rvm_which curl > /dev/null || {
        rvm_error "RVM requires 'curl'. Install 'curl' first and try again.";
        return 200
    };
    typeset -a __flags;
    __flags=(--fail --location --max-redirs 10);
    if [[ -n "${rvm_proxy:-}" ]]; then
        __flags+=(--proxy "${rvm_proxy:-}");
    fi;
    __rvm_curl_output_control;
    unset curl;
    __rvm_debug_command \curl "${__flags[@]}" "$@" || return $? )
}
__rvm_curl_output_control ()
{
    if (( ${rvm_quiet_curl_flag:-0} == 1 )); then
        __flags+=("--silent" "--show-error");
    else
        if [[ " $*" =~ " -s" || " $*" =~ " --silent" ]]; then
            [[ " $*" =~ " -S" || " $*" =~ " -sS" || " $*" =~ " --show-error" ]] || {
                __flags+=("--show-error")
            };
        fi;
    fi
}
__rvm_current_gemcache_dir ()
{
    if __rvm_using_gemset_globalcache; then
        echo "$rvm_gems_cache_path";
    else
        echo "${rvm_ruby_gem_home:-"$GEM_HOME"}/cache";
    fi;
    return 0
}
__rvm_current_gemset ()
{
    typeset current_gemset;
    current_gemset="${GEM_HOME:-}";
    current_gemset="${current_gemset##*${rvm_gemset_separator:-@}}";
    if [[ "${current_gemset}" == "${GEM_HOME:-}" ]]; then
        echo '';
    else
        echo "${current_gemset}";
    fi
}
__rvm_custom_separated_array ()
{
    typeset IFS;
    IFS=$2;
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        eval "$1+=( \${=3} )";
    else
        eval "$1+=( \$3 )";
    fi
}
__rvm_db ()
{
    typeset value key variable;
    key=${1:-""};
    key=${key#go};
    variable=${2:-""};
    if [[ -f "$rvm_user_path/db" ]]; then
        value="$("$rvm_scripts_path/db" "$rvm_user_path/db" "$key")";
    fi;
    if [[ -z "$value" ]]; then
        value="$("$rvm_scripts_path/db" "$rvm_path/config/db" "$key")";
    fi;
    if [[ -n "$value" ]]; then
        if [[ -z "$variable" ]]; then
            echo $value;
        else
            eval "$variable='$value'";
        fi;
    fi;
    return 0
}
__rvm_debug_command ()
{
    rvm_debug "Running($#): $*";
    "$@" || return $?
}
__rvm_default_flags ()
{
    true ${rvm_head_flag:=0} ${rvm_delete_flag:=0}
}
__rvm_detect_system ()
{
    unset _system_type _system_name _system_version _system_arch;
    export _system_type _system_name _system_version _system_arch;
    _system_type="unknown";
    _system_name="unknown";
    _system_version="unknown";
    _system_arch="$(uname -m)";
    case "$(uname)" in
        Linux | GNU*)
            _system_type="linux";
            if [[ -f /etc/lsb-release ]] && GREP_OPTIONS="" \grep "DISTRIB_ID=Ubuntu" /etc/lsb-release > /dev/null; then
                _system_name="ubuntu";
                _system_version="$(awk -F'=' '$1=="DISTRIB_RELEASE"{print $2}' /etc/lsb-release)";
                _system_arch="$( dpkg --print-architecture )";
            else
                if [[ -f /etc/lsb-release ]] && GREP_OPTIONS="" \grep "DISTRIB_ID=LinuxMint" /etc/lsb-release > /dev/null; then
                    _system_name="mint";
                    _system_version="$(awk -F'=' '$1=="DISTRIB_RELEASE"{print $2}' /etc/lsb-release)";
                    _system_arch="$( dpkg --print-architecture )";
                else
                    if [[ -f /etc/lsb-release ]] && GREP_OPTIONS="" \grep "DISTRIB_ID=ManjaroLinux" /etc/lsb-release > /dev/null; then
                        _system_name="manjaro";
                        _system_version="$(awk -F'=' '$1=="DISTRIB_RELEASE"{print $2}' /etc/lsb-release)";
                    else
                        if [[ -f /etc/os-release ]] && GREP_OPTIONS="" \grep "ID=opensuse" /etc/os-release > /dev/null; then
                            _system_name="opensuse";
                            _system_version="$(awk -F'=' '$1=="VERSION_ID"{gsub(/"/,"");print $2}' /etc/os-release)";
                        else
                            if [[ -f /etc/SuSE-release ]]; then
                                _system_name="suse";
                                _system_version="$(
          awk -F'=' '{gsub(/ /,"")} $1~/VERSION/ {version=$2} $1~/PATCHLEVEL/ {patch=$2} END {print version"."patch}' < /etc/SuSE-release
        )";
                            else
                                if [[ -f /etc/debian_version ]]; then
                                    _system_name="debian";
                                    _system_version="$(\cat /etc/debian_version | awk -F. '{print $1"."$2}')";
                                    _system_arch="$( dpkg --print-architecture )";
                                else
                                    if [[ -f /etc/os-release ]] && GREP_OPTIONS="" \grep "ID=debian" /etc/os-release > /dev/null; then
                                        _system_name="debian";
                                        _system_version="$(awk -F'=' '$1=="VERSION_ID"{gsub(/"/,"");print $2}' /etc/os-release | awk -F. '{print $1"."$2}')";
                                        _system_arch="$( dpkg --print-architecture )";
                                    else
                                        if [[ -f /etc/fedora-release ]]; then
                                            _system_name="fedora";
                                            _system_version="$(\grep -Eo '[[:digit:]]+' /etc/fedora-release)";
                                        else
                                            if [[ -f /etc/centos-release ]]; then
                                                _system_name="centos";
                                                _system_version="$(\grep -Eo '[[:digit:]\.]+' /etc/centos-release  | awk -F. '{print $1"."$2}')";
                                            else
                                                if [[ -f /etc/redhat-release ]]; then
                                                    if \grep CentOS /etc/redhat-release > /dev/null; then
                                                        _system_name="centos";
                                                    else
                                                        _system_name="redhat";
                                                    fi;
                                                    _system_version="$(\grep -Eo '[[:digit:]\.]+' /etc/redhat-release  | awk -F. '{print $1"."$2}')";
                                                else
                                                    if [[ -f /etc/system-release ]] && GREP_OPTIONS="" \grep "Amazon Linux AMI" /etc/system-release > /dev/null; then
                                                        _system_name="amazon";
                                                        _system_version="$(\grep -Eo '[[:digit:]\.]+' /etc/system-release | awk -F. '{print $1"."$2}')";
                                                    else
                                                        if [[ -f /etc/sabayon-release ]]; then
                                                            _system_name="sabayon";
                                                            _system_version="$(\cat /etc/sabayon-release | awk 'NR==1 {print $NF}' | awk -F. '{print $1"."$2}')";
                                                        else
                                                            if [[ -f /etc/gentoo-release ]]; then
                                                                _system_name="gentoo";
                                                                _system_version="base-$(\cat /etc/gentoo-release | awk 'NR==1 {print $NF}' | awk -F. '{print $1"."$2}')";
                                                            else
                                                                if [[ -f /etc/arch-release ]]; then
                                                                    _system_name="arch";
                                                                    _system_version="libc-$(ldd --version  | awk 'NR==1 {print $NF}' | awk -F. '{print $1"."$2}')";
                                                                else
                                                                    _system_version="libc-$(ldd --version  | awk 'NR==1 {print $NF}' | awk -F. '{print $1"."$2}')";
                                                                fi;
                                                            fi;
                                                        fi;
                                                    fi;
                                                fi;
                                            fi;
                                        fi;
                                    fi;
                                fi;
                            fi;
                        fi;
                    fi;
                fi;
            fi
        ;;
        SunOS)
            _system_type="sunos";
            _system_name="solaris";
            _system_version="$(uname -v)";
            if __rvm_string_match "${_system_version}" "joyent*"; then
                _system_name="smartos";
                _system_version="${_system_version#* }";
            else
                if __rvm_string_match "${_system_version}" "oi*"; then
                    _system_name="openindiana";
                    _system_version="${_system_version#* }";
                fi;
            fi
        ;;
        OpenBSD)
            _system_type="bsd";
            _system_name="openbsd";
            _system_version="$(uname -r)"
        ;;
        Darwin)
            _system_type="darwin";
            _system_name="osx";
            _system_version="$(sw_vers -productVersion | awk -F. '{print $1"."$2}')"
        ;;
        FreeBSD)
            _system_type="bsd";
            _system_name="freebsd";
            _system_version="$(uname -r)";
            _system_version="${_system_version%%-*}"
        ;;
        *)
            return 1
        ;;
    esac;
    _system_type="${_system_type//[ \/]/_}";
    _system_name="${_system_name//[ \/]/_}";
    _system_version="${_system_version//[ \/]/_}";
    _system_arch="${_system_arch//[ \/]/_}";
    _system_arch="${_system_arch/amd64/x86_64}";
    _system_arch="${_system_arch/i[123456789]86/i386}"
}
__rvm_detect_xcode_version ()
{
    typeset version_file;
    for version_file in /Applications/Xcode.app/Contents/version.plist /Developer/Applications/Xcode.app/Contents/version.plist;
    do
        if [[ -f $version_file ]]; then
            if [[ -x /usr/libexec/PlistBuddy ]]; then
                /usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" $version_file;
            else
                sed -n '/<key>CFBundleShortVersionString<\/key>/{n; s/^.*>\(.*\)<.*$/\1/; p;}' < $version_file;
            fi;
            return 0;
        fi;
    done;
    if builtin command -v xcodebuild > /dev/null; then
        xcodebuild -version | sed -n '/Xcode/ {s/Xcode //; p;}';
        return 0;
    fi;
    return 1
}
__rvm_detect_xcode_version_at_least ()
{
    typeset __xcode_version="$(__rvm_detect_xcode_version)";
    [[ -n "$__xcode_version" ]] || return 0;
    __rvm_version_compare "$__xcode_version" -ge "$1" || return $?;
    true
}
__rvm_display_rvmrc ()
{
    typeset _rvmrc_base;
    _rvmrc_base="$(basename "${_rvmrc}")";
    __rvm_table  <<-TEXT
The contents of the ${_rvmrc_base} file will now be displayed.
After reading the file, you will be prompted again for 'yes or no' to set the trust level for this particular version of the file.

Note: You will be re-prompted each time the ${_rvmrc_base} file's contents change
changes, and may change the trust setting manually at any time.
TEXT

    __rvm_wait_anykey "(( press a key to review the ${_rvmrc_base} file ))";
    printf "%b" "${rvm_warn_clr}";
    command cat -v "${_rvmrc}";
    printf "%b" "${rvm_reset_clr}";
    __rvm_table "Viewing of ${_rvmrc} complete."  <<-TEXT
Trusting an ${_rvmrc_base} file means that whenever you cd into this directory, RVM will run this ${_rvmrc_base} shell script.
Note that if the contents of the file change, you will be re-prompted to review the file and adjust its trust settings. You may also change the trust settings manually at any time with the 'rvm rvmrc' command.
TEXT

}
__rvm_do_with_env ()
{
    typeset result;
    __rvm_do_with_env_before;
    "$@";
    result=$?;
    __rvm_do_with_env_after;
    return ${result:-0}
}
__rvm_do_with_env_after ()
{
    __rvm_teardown
}
__rvm_do_with_env_before ()
{
    if [[ -n "${rvm_scripts_path:-}" || -n "${rvm_path:-}" ]]; then
        source "${rvm_scripts_path:-"$rvm_path/scripts"}/initialize";
        __rvm_setup;
    fi
}
__rvm_dotted ()
{
    typeset flush __show_nth_dot;
    __show_nth_dot=${rvm_show_every_nth_dot:-1};
    unset rvm_show_every_nth_dot;
    if (( __show_nth_dot == 1 )); then
        __show_nth_dot="";
    else
        __show_nth_dot="if (NR%${__show_nth_dot}==1)";
    fi;
    if awk '{fflush;}' <<< EO 2> /dev/null; then
        flush=fflush;
    else
        flush=flush;
    fi;
    if (( $# )); then
        awk '{if (NR==1){printf "'"${rvm_notify_clr:-}$*${rvm_reset_clr:-}"'"}; '"$__show_nth_dot"' printf "."; '$flush';} END{if (NR>0) print ""; else print "'"${rvm_notify_clr:-}$*${rvm_reset_clr:-}"'"}';
    else
        awk '{printf "."; '$flush';} END{if (NR>0) print ""}';
    fi
}
__rvm_dotted_run ()
{
    typeset __message="$1";
    shift;
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        rvm_log "${__message} - using Zsh, can not show progress, be patient...";
        "$@" > "${__log_file}" 2>&1 || return $?;
    else
        "$@" | tee -a "${__log_file}" | __rvm_dotted "${__message}";
        __rvm_check_pipestatus ${PIPESTATUS[@]} ${pipestatus[@]} || return $?;
    fi
}
__rvm_ensure_has_environment_files ()
{
    typeset environment_id file_name directory identifier variable value variables;
    environment_id="$(__rvm_env_string)";
    file_name="${rvm_environments_path}/$environment_id";
    if [[ ! -d "$rvm_environments_path" ]]; then
        \mkdir -p "$rvm_environments_path";
    fi;
    if [[ ! -s "$file_name" ]] || ! GREP_OPTIONS="" \grep 'rvm_env_string=' "$file_name" > /dev/null; then
        \rm -f "$file_name";
        printf "%b" "export PATH ; PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path}:\$PATH\"\n" > "$file_name";
        for variable in rvm_env_string rvm_path rvm_ruby_string rvm_gemset_name RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC MAGLEV_HOME RBXOPT;
        do
            eval "export $variable";
            eval "value=\${${variable}:-""}";
            if [[ -n "$value" ]]; then
                printf "export %b ; %b='%b'\n" "${variable}" "${variable}" "${value}" >> "$file_name";
            else
                printf "unset %b\n" "${variable}" >> "$file_name";
            fi;
        done;
    fi;
    if (( ${rvm_create_default_wrappers:=0} == 1 )) || [[ ! -f "$rvm_wrappers_path/$environment_id/ruby" ]]; then
        for identifier in "$environment_id" "${environment_id//@*/}@global";
        do
            rvm_create_default_wrappers=1;
            directory="$rvm_wrappers_path/$identifier";
            if [[ ! -L "$directory" && ! -d "$directory" ]]; then
                \mkdir -p "$directory";
                "$rvm_scripts_path/wrapper" "$identifier" >&/dev/null;
            fi;
        done;
        rvm_create_default_wrappers=0;
    fi;
    return 0
}
__rvm_ensure_is_a_function ()
{
    if [[ ${rvm_reload_flag:=0} == 1 ]] || ! is_a_function rvm; then
        for script in version selector selector_gemsets cd cli override_gem;
        do
            if [[ -f "$rvm_scripts_path/$script" ]]; then
                source "$rvm_scripts_path/$script";
            else
                printf "%b" "WARNING:
        Could not source '$rvm_scripts_path/$script' as file does not exist.
        RVM will likely not work as expected.\n";
            fi;
        done;
    fi
}
__rvm_env_string ()
{
    typeset _path _string;
    _path="${GEM_HOME:-""}";
    _string="${_path//*gems\//}";
    _string="${_string//\/*/}";
    printf "%b" "${_string:-system}\n"
}
__rvm_every_nth_dot ()
{
    typeset result=0;
    export rvm_show_every_nth_dot=$1;
    shift;
    "$@" || result=$?;
    unset rvm_show_every_nth_dot;
    return $result
}
__rvm_expand_ruby_string ()
{
    typeset string current_ruby;
    string="$1";
    case "${string:-all}" in
        all)
            "$rvm_scripts_path/list" strings | \tr ' ' "\n"
        ;;
        all-gemsets)
            "$rvm_scripts_path/list" gemsets strings
        ;;
        default-with-rvmrc | rvmrc)
            "$rvm_scripts_path/tools" path-identifier "$PWD"
        ;;
        all-rubies | rubies)
            "$rvm_scripts_path/list" rubies strings
        ;;
        current-ruby | gemsets)
            current_ruby="$(__rvm_env_string)";
            current_ruby="${current_ruby%@*}";
            rvm_silence_logging=1 "$rvm_scripts_path/gemsets" list strings | \sed "s/ (default)//; s/^/$current_ruby${rvm_gemset_separator:-@}/ ; s/@default// ;"
        ;;
        current)
            __rvm_env_string
        ;;
        aliases)
            awk -F= '{print $string}' < "$rvm_path/config/alias"
        ;;
        *)
            __rvm_ruby_strings_exist $( echo "$string" | \tr "," "\n" | __rvm_strip )
        ;;
    esac
}
__rvm_export ()
{
    typeset name;
    name=${1%%\=*};
    builtin export rvm_old_$name=${!name};
    export "$@";
    return $?
}
__rvm_find_first_file ()
{
    typeset _first_file _variable_first_file __file_enum;
    _first_file="";
    _variable_first_file="$1";
    shift;
    for __file_enum in "$@";
    do
        if [[ -f "$__file_enum" ]]; then
            eval "$_variable_first_file=\"\$__file_enum\"";
            return 0;
        fi;
    done;
    eval "$_variable_first_file=\"\"";
    return 1
}
__rvm_fix_group_permissions ()
{
    if umask -S | GREP_OPTIONS="" \grep 'g=rw' > /dev/null; then
        chmod -R g+rwX "$@";
    fi
}
__rvm_fix_path_from_gem_path ()
{
    [[ -n "${GEM_PATH:-}" ]] || return 0;
    export PATH;
    typeset IFS _iterator_path;
    typeset -a _gem_path _new_path;
    IFS=:;
    _gem_path=();
    _new_path=();
    __rvm_custom_separated_array _gem_path : "${GEM_PATH}";
    for _iterator_path in "${_gem_path[@]}";
    do
        _new_path+=("${_iterator_path}/bin");
    done;
    _new_path+=("${MY_RUBY_HOME:-${GEM_HOME/gems/rubies}}/bin");
    _new_path+=("${rvm_bin_path}");
    PATH="${_new_path[*]}:$PATH";
    builtin hash -r
}
__rvm_fix_selected_ruby ()
{
    typeset __ret=0;
    if (( $# )); then
        "$@" || __ret=$?;
    fi;
    [[ -d "$GEM_HOME" && -d "$MY_RUBY_HOME" ]] || {
        if [[ -d ${MY_RUBY_HOME%/*}/defaul ]]; then
            __rvm_use default;
        else
            __rvm_use system;
        fi
    }
}
__rvm_fold ()
{
    if fold -s -w 10 <<< bla > /dev/null; then
        fold -s -w $1;
    else
        fold -w $1;
    fi
}
__rvm_gemset_clear ()
{
    export rvm_gemset_name;
    rvm_gemset_name="";
    __rvm_use
}
__rvm_gemset_handle_default ()
{
    rvm_gemset_name="@${rvm_gemset_name:-}@";
    rvm_gemset_name="${rvm_gemset_name/@default@/@@}";
    rvm_gemset_name="${rvm_gemset_name#@}";
    rvm_gemset_name="${rvm_gemset_name%@}"
}
__rvm_gemset_pristine ()
{
    __rvm_log_command "gemset.pristine-$1" "Making gemset $1 pristine." __rvm_with "$1" "$rvm_scripts_path/gemsets" pristine
}
__rvm_gemset_select ()
{
    __rvm_gemset_select_only && __rvm_gemset_select_validation && __rvm_gemset_select_ensure
}
__rvm_gemset_select_cli ()
{
    __rvm_gemset_select_cli_validation && __rvm_gemset_select
}
__rvm_gemset_select_cli_validation ()
{
    typeset orig_gemset;
    if ! builtin command -v gem > /dev/null; then
        rvm_log "'gem' command not found, cannot select a gemset.";
        return 0;
    fi;
    orig_gemset="${rvm_gemset_name:-}";
    __rvm_gemset_handle_default;
    if [[ -z "${rvm_gemset_name:-}" && "$orig_gemset" != "default" && ${rvm_sticky_flag:-0} -eq 1 ]]; then
        if [[ -n "${rvm_ruby_gem_home:-}" ]]; then
            rvm_gemset_name="$rvm_ruby_gem_home";
        else
            if [[ -n "${GEM_HOME:-}" ]]; then
                rvm_gemset_name="$GEM_HOME";
            fi;
        fi;
        rvm_gemset_name="${rvm_gemset_name##*/}";
        rvm_gemset_name="${rvm_gemset_name#*${rvm_gemset_separator:-"@"}}";
    fi;
    if [[ -z "${rvm_ruby_string:-}" && -n "${GEM_HOME:-}" && -n "${GEM_HOME%@*}" ]]; then
        rvm_ruby_string="${GEM_HOME%@*}";
        rvm_ruby_string="${rvm_ruby_string##*/}";
    fi;
    if [[ -z "${rvm_ruby_string:-}" ]]; then
        rvm_error "Gemsets can not be used with non rvm controlled rubies (currently).";
        return 3;
    fi
}
__rvm_gemset_select_ensure ()
{
    \mkdir -p "$rvm_ruby_gem_home";
    if __rvm_using_gemset_globalcache && [[ ! -L "$rvm_ruby_gem_home/cache" ]]; then
        : rvm_gems_cache_path:${rvm_gems_cache_path:=${rvm_gems_path:-"$rvm_path/gems"}/cache};
        \mv "$rvm_ruby_gem_home/cache/"*.gem "$rvm_gems_cache_path/" 2> /dev/null;
        __rvm_rm_rf "$rvm_ruby_gem_home/cache";
        \ln -fs "$rvm_gems_cache_path" "$rvm_ruby_gem_home/cache";
    fi
}
__rvm_gemset_select_only ()
{
    rvm_ruby_gem_home="${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string";
    : rvm_ignore_gemsets_flag:${rvm_ignore_gemsets_flag:=0}:;
    if (( rvm_ignore_gemsets_flag )); then
        rvm_ruby_global_gems_path="${rvm_ruby_gem_home}";
        rvm_ruby_gem_path="${rvm_ruby_gem_home}";
        rvm_gemset_name="";
    else
        rvm_ruby_global_gems_path="${rvm_ruby_gem_home}${rvm_gemset_separator:-"@"}global";
        __rvm_gemset_handle_default;
        [[ -z "$rvm_gemset_name" ]] || rvm_ruby_gem_home="${rvm_ruby_gem_home}${rvm_gemset_separator:-"@"}${rvm_gemset_name}";
        if [[ "$rvm_gemset_name" == "global" ]]; then
            rvm_ruby_gem_path="${rvm_ruby_gem_home}";
        else
            rvm_ruby_gem_path="${rvm_ruby_gem_home}:${rvm_ruby_global_gems_path}";
        fi;
    fi;
    if [[ -n "${rvm_gemset_name}" ]]; then
        rvm_env_string="${rvm_ruby_string}@${rvm_gemset_name}";
    else
        rvm_env_string=${rvm_ruby_string};
    fi;
    true
}
__rvm_gemset_select_validation ()
{
    if [[ ! -d "${rvm_ruby_gem_home}" ]]; then
        if (( ${rvm_gemset_create_on_use_flag:=0} == 0 && ${rvm_create_flag:=0} == 0 && ${rvm_delete_flag:=0} == 0 )); then
            rvm_expected_gemset_name="${rvm_gemset_name}";
            rvm_gemset_name="";
            __rvm_gemset_select_only;
            return 2;
        fi;
    else
        if (( ${rvm_delete_flag:=0} == 1 )); then
            return 4;
        fi;
    fi;
    case "${rvm_gemset_name}" in
        */*)
            rvm_error "Gemsets can not contain path separator '/'.";
            return 5
        ;;
        *:*)
            rvm_error "Gemsets can not contain PATH separator ':'.";
            return 5
        ;;
    esac;
    typeset rvm_ruby_gem_home_254;
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        rvm_ruby_gem_home_254="${rvm_ruby_gem_home[0,254]}";
    else
        rvm_ruby_gem_home_254="${rvm_ruby_gem_home:0:254}";
    fi;
    if [[ "${rvm_ruby_gem_home}" != "${rvm_ruby_gem_home_254}" ]]; then
        rvm_error "Gemset gem home to long ${#rvm_ruby_gem_home}.";
        return 6;
    fi
}
__rvm_gemset_use ()
{
    if __rvm_gemset_select_cli; then
        rvm_log "Using $rvm_ruby_string with gemset ${rvm_gemset_name:-default}";
        __rvm_use;
    else
        if [[ ! -d "$rvm_ruby_gem_home" || -n "${rvm_expected_gemset_name}" ]]; then
            if (( ${rvm_gemset_create_on_use_flag:=0} == 1 || ${rvm_create_flag:=0} == 1 )); then
                rvm_warn "gemset $rvm_gemset_name is not existing, creating.";
                "$rvm_scripts_path/gemsets" create "$rvm_gemset_name";
            else
                rvm_error "Gemset '${rvm_expected_gemset_name}' does not exist, 'rvm $rvm_ruby_string do rvm gemset create ${rvm_expected_gemset_name}' first, or append '--create'.";
                return 2;
            fi;
        else
            rvm_error "Gemset was not given.\n  Usage:\n    rvm gemset use <gemsetname>\n";
            return 1;
        fi;
    fi
}
__rvm_gemsets_initial ()
{
    if (( ${rvm_skip_gemsets_flag:-0} == 0 )); then
        __rvm_log_command "gemsets.initial" "$rvm_ruby_string - #importing default gemsets, this may take time" __rvm_with "$rvm_ruby_string" "$rvm_scripts_path/gemsets" initial;
    else
        mkdir -p "$rvm_gems_path/$rvm_ruby_string/bin" "$rvm_gems_path/$rvm_ruby_string@global/bin";
        rvm_log "Skipped importing default gemsets";
    fi
}
__rvm_generate_wrappers ()
{
    "$rvm_scripts_path/wrapper" "$rvm_ruby_string" --no-links --all
}
__rvm_get_user_shell ()
{
    case "$(uname)" in
        *BSD | Linux | SunOS)
            awk -F: "/$USER/"'{print $NF}' < /etc/passwd || {
                rvm_error "Error checking user shell via /etc/passwd - make sure this file is word readable.";
                return 2
            }
        ;;
        Darwin)
            typeset __version;
            __version="$(dscl localhost -read "/Local/Default/Users/$USER" shell)" || {
                rvm_error "Error checking user shell via dscl ... something went wrong, report a bug.";
                return 3
            };
            echo ${__version#*: }
        ;;
        *)
            rvm_error "Do not know how to check user shell on '$(uname)'.";
            return 1
        ;;
    esac
}
__rvm_has_opt ()
{
    if [[ -n "${ZSH_VERSION}" ]] && setopt | GREP_OPTIONS="" \grep "^${1}$" > /dev/null 2>&1; then
        return 0;
    else
        if [[ -n "${BASH_VERSION}" ]] && [[ ":$SHELLOPTS:" =~ ":${1}:" ]]; then
            return 0;
        else
            return 1;
        fi;
    fi
}
__rvm_initialize ()
{
    true ${rvm_scripts_path:="$rvm_path/scripts"};
    source "$rvm_scripts_path/base";
    __rvm_clean_path;
    __rvm_conditionally_add_bin_path;
    export PATH;
    if [[ ! -d "${rvm_tmp_path:-/tmp}" ]]; then
        command mkdir -p "${rvm_tmp_path}";
    fi;
    return 0
}
__rvm_join_array ()
{
    typeset IFS;
    IFS="$2";
    eval "$1=\"\${$3[*]}\""
}
__rvm_load_environment ()
{
    typeset string __hook;
    string="$1";
    if [[ -f "$rvm_environments_path/$string" ]]; then
        __rvm_remove_rvm_from_path;
        \. "$rvm_environments_path/$string";
        for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*;
        do
            if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]; then
                \. "${__hook}" || true;
            fi;
        done;
        builtin hash -r;
    else
        if [[ -n "$string" ]]; then
            rvm "$string";
        else
            :;
        fi;
    fi
}
__rvm_load_project_config ()
{
    typeset __gemfile;
    : rvm_autoinstall_bundler_flag:${rvm_autoinstall_bundler_flag:=0};
    case "$1" in
        */.rvmrc)
            __rvmrc_warning_display_for_rvmrc "$1";
            if __rvm_check_rvmrc_trustworthiness "$1"; then
                __rvm_remove_rvm_from_path;
                __rvm_conditionally_add_bin_path;
                rvm_previous_environment="$(__rvm_env_string)";
                rvm_current_rvmrc="$1";
                __rvm_ensure_is_a_function;
                rvm_action=use source "$1";
            else
                return $?;
            fi
        ;;
        */.versions.conf)
            typeset _gem _gem_names _bundle_install;
            __rvm_ensure_is_a_function;
            rvm_previous_environment="$(__rvm_env_string)";
            rvm_current_rvmrc="$1";
            rvm_ruby_string="$( \tr -d '\r' <"$1" | sed -n '/^ruby=/ {s/ruby=//;p;}' )";
            [[ -n "${rvm_ruby_string}" ]] || return 2;
            rvm_gemset_name="$( \tr -d '\r' <"$1" | sed -n '/^ruby-gemset=/ {s/ruby-gemset=//;p;}' )";
            rvm_create_flag=1 __rvm_use || return 3;
            _gem_names="$( \tr -d '\r' <"$1" | sed -n '/^ruby-gem-install=/ {s/ruby-gem-install=//;p;}' )";
            for _gem in ${_gem_names//,/ };
            do
                gem list | GREP_OPTIONS="" \grep "^${_gem} " > /dev/null || gem install "${_gem}";
            done;
            _bundle_install="$( \tr -d '\r' <"$1" | sed -n '/^ruby-bundle-install=/ {s/ruby-bundle-install=//;p;}' )";
            if [[ -n "${_bundle_install}" ]] || [[ "${rvm_autoinstall_bundler_flag:-0}" == 1 ]]; then
                if [[ "${_bundle_install}" == true ]]; then
                    __gemfile="${1%/*}/Gemfile";
                else
                    if [[ -f "${_bundle_install}" ]]; then
                        __gemfile="${_bundle_install}";
                    else
                        if [[ "${rvm_autoinstall_bundler_flag:-0}" == 1 ]]; then
                            __gemfile="${1%/*}/Gemfile";
                        fi;
                    fi;
                fi;
            fi
        ;;
        */Gemfile)
            __rvm_ensure_is_a_function;
            rvm_previous_environment="$(__rvm_env_string)";
            rvm_current_rvmrc="$1";
            rvm_ruby_string="$( \tr -d '\r' <"$1" | sed -n '/^#ruby=/ {s/#ruby=//;p;}' )";
            [[ -n "${rvm_ruby_string}" ]] || {
                rvm_ruby_string="$( \tr -d '\r' <"$1" | sed -n "s/ rescue nil$//; /^\s*ruby/ {s/^\s*ruby//; s/[ ()'\"]//g; p;}" )";
                [[ -n "${rvm_ruby_string}" ]] || return 2
            };
            rvm_gemset_name="$( \tr -d '\r' <"$1" | sed -n '/^#ruby-gemset=/ {s/#ruby-gemset=//;p;}' )";
            __rvmrc_warning_display_for_Gemfile "$1";
            rvm_create_flag=1 __rvm_use || return 3;
            if [[ "${rvm_autoinstall_bundler_flag:-0}" == "1" ]]; then
                __gemfile="$1";
                gem list | GREP_OPTIONS="" \grep "^bundler " > /dev/null || gem install bundler;
            fi
        ;;
        */.ruby-version | */.rbfu-version | */.rbenv-version)
            __rvm_ensure_is_a_function;
            rvm_previous_environment="$(__rvm_env_string)";
            rvm_current_rvmrc="$1";
            rvm_ruby_string="$( \tr -d '\r' <"$1" )";
            [[ -n "${rvm_ruby_string}" ]] || return 2;
            if [[ -f "${1%/*}/.ruby-gemset" ]]; then
                rvm_gemset_name="$( \tr -d '\r' <"${1%/*}/.ruby-gemset" )";
            fi;
            rvm_create_flag=1 __rvm_use || return 3;
            if [[ "${rvm_autoinstall_bundler_flag:-0}" == 1 && -f "${1%/*}/Gemfile" ]]; then
                gem list | GREP_OPTIONS="" \grep "^bundler " > /dev/null || gem install "bundler";
                __gemfile="${1%/*}/Gemfile";
            fi
        ;;
        *)
            rvm_error "Unsupported file format for '$1'";
            return 1
        ;;
    esac;
    if [[ -n "${__gemfile:-}" && -f "${__gemfile:-}" ]]; then
        bundle install --gemfile="${__gemfile}" | GREP_OPTIONS="" \grep -vE '^Using|Your bundle is complete';
    fi
}
__rvm_load_rvmrc ()
{
    typeset _file;
    typeset -a rvm_rvmrc_files;
    if (( ${rvm_ignore_rvmrc:=0} == 1 )); then
        return 0;
    fi;
    [[ -n "${rvm_stored_umask:-}" ]] || export rvm_stored_umask=$(umask);
    rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc");
    if [[ -n "${rvm_prefix:-}" ]] && ! [[ "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]; then
        rvm_rvmrc_files+=("${rvm_prefix}/.rvmrc");
    fi;
    for _file in "${rvm_rvmrc_files[@]}";
    do
        if [[ -s "$_file" ]]; then
            if GREP_OPTIONS="" \grep '^\s*rvm .*$' "$_file" > /dev/null 2>&1; then
                rvm_error "
$_file is for rvm settings only.
rvm CLI may NOT be called from within $_file.
Skipping the loading of $_file
";
                return 1;
            else
                source "$_file";
            fi;
        fi;
    done;
    return 0
}
__rvm_log_command ()
{
    typeset name message _log _command_start _command_name;
    typeset -a _command;
    name="${1:-}";
    message="${2:-}";
    shift 2;
    _command=("$@");
    _command_start="$1";
    while (( $# )) && [[ "$1" =~ "=" ]]; do
        shift;
    done;
    _command_name="$1";
    [[ ! "${_command_start}" =~ "=" ]] || _command=("env" "${_command[@]}");
    (( ${rvm_niceness:-0} == 0 )) || _command=(nice -n $rvm_niceness "${_command[@]}");
    __rvm_log_command_caclulate_log_file_name;
    rvm_debug "Log file: ${_log}";
    [[ -d "${_log%\/*}" ]] || \mkdir -p "${_log%\/*}";
    [[ -f "${_log}" ]] || \rm -f "${_log}";
    {
        printf "%b" "[$(date +'%Y-%m-%d %H:%M:%S')] ${_command_name}\n";
        if is_a_function "${_command_name}"; then
            typeset -f "${_command_name}";
        fi;
        printf "%b" "current path: $PWD\n";
        printf "%b" "command(${#_command[@]}): ${_command[*]}\n"
    } | tee "${_log}" | rvm_debug_stream;
    __rvm_log_dotted "${_log}" "$message" "${_command[@]}" || {
        typeset result=$?;
        rvm_error "Error running '${_command[*]}',
please read ${_log}";
        return ${result}
    }
}
__rvm_log_command_caclulate_log_file_name ()
{
    _log="${rvm_log_path}${rvm_ruby_string:+/}${rvm_ruby_string:-}/$(date "+%s")_${name}";
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        _log="${_log[0,250]}.log";
    else
        _log="${_log:0:250}.log";
    fi
}
__rvm_log_dotted ()
{
    typeset __log_file __message __iterator;
    __log_file="$1";
    __message="$2";
    shift 2;
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        rvm_log "${__message} - using Zsh, can not show progress, be patient...";
        "$@" > "${__log_file}" 2>&1 || return $?;
    else
        "$@" 2>&1 | tee -a "${__log_file}" | __rvm_dotted "${__message}";
        __rvm_check_pipestatus ${PIPESTATUS[@]} ${pipestatus[@]} || return $?;
    fi
}
__rvm_md5_calculate ()
{
    typeset _sum;
    if builtin command -v md5 > /dev/null 2>&1; then
        _sum=$(md5 "$@");
        echo ${_sum##* };
        return 0;
    else
        if builtin command -v md5sum > /dev/null 2>&1; then
            _sum=$(md5sum "$@");
            echo ${_sum%% *};
            return 0;
        else
            for _path in /usr/gnu/bin /sbin /bin /usr/bin /usr/sbin;
            do
                if [[ -x "${_path}/md5" ]]; then
                    _sum=$(${_path}/md5 "$@");
                    echo ${_sum##* };
                    return 0;
                else
                    if [[ -x "${_path}/md5sum" ]]; then
                        _sum=$(${_path}/md5sum "$@");
                        echo ${_sum%% *};
                        return 0;
                    fi;
                fi;
            done;
        fi;
    fi;
    rvm_error "Neither md5sum nor md5 found in the PATH";
    return 1
}
__rvm_md5_for_contents ()
{
    if builtin command -v md5 > /dev/null; then
        md5 | awk '{print $1}';
    else
        if builtin command -v md5sum > /dev/null; then
            md5sum | awk '{print $1}';
        else
            if builtin command -v openssl > /dev/null; then
                openssl md5 | awk '{print $1}';
            else
                return 1;
            fi;
        fi;
    fi;
    true
}
__rvm_meta ()
{
    rvm_meta_author="Wayne E. Seguin";
    rvm_meta_author_email="wayneeseguin@gmail.com";
    rvm_meta_authors=("Wayne E. Seguin <wayneeseguin@gmail.com>" "Michal Papis <mpapis@gmail.com>");
    rvm_meta_website="https://rvm.io/";
    rvm_meta_version="${rvm_version}"
}
__rvm_nuke_rvm_variables ()
{
    unset rvm_head_flag $(env | awk -F= '/^rvm_/{print $1" "}')
}
__rvm_package_create ()
{
    rvm_debug __rvm_package_create:$#: "$@";
    case "$1" in
        *.tar.bz2)
            if [[ -z "${3:-}" ]]; then
                ${rvm_tar_command:-tar} cjf "$1" "$2";
            else
                ${rvm_tar_command:-tar} cjf "$1" -C "$2" "$3";
            fi
        ;;
        *.tar.gz | *.tgz)
            if [[ -z "${3:-}" ]]; then
                ${rvm_tar_command:-tar} czf "$1" "$2";
            else
                ${rvm_tar_command:-tar} czf "$1" -C "$2" "$3";
            fi
        ;;
        *)
            return 199
        ;;
    esac
}
__rvm_package_extract ()
{
    rvm_debug __rvm_package_extract:$#: "$@";
    typeset __tempdir __path __file __return;
    __return=0;
    __tempdir="$( TMPDIR="${rvm_tmp_path}" mktemp -d -t rvm-tmp.XXXXXXXXX )";
    __rvm_package_extract_run "$1" "$__tempdir" || __return=$?;
    if (( __return == 0 )); then
        for __path in "$__tempdir"/*;
        do
            __file="${__path##*/}";
            if [[ -n "${__file}" && -e "$2/${__file}" ]]; then
                \rm -rf "$2/${__file}" || __return=$?;
            fi;
            \mv -f "${__path}" "$2/" || __return=$?;
        done;
    fi;
    if [[ -n "$__tempdir" ]]; then
        \rm -rf "$__tempdir";
    fi;
    return $__return
}
__rvm_package_extract_run ()
{
    [[ -d "$2" ]] || mkdir -p "$2";
    case "$1" in
        *.zip)
            unzip -q -o "$1" -d "$2"
        ;;
        *.tar.bz2)
            if [[ -n "$ZSH_VERSION" ]]; then
                ${rvm_tar_command:-tar} xjf "$1" -C "$2" ${=rvm_tar_options:-};
            else
                ${rvm_tar_command:-tar} xjf "$1" -C "$2" ${rvm_tar_options:-};
            fi
        ;;
        *.tar.gz | *.tgz)
            if [[ -n "$ZSH_VERSION" ]]; then
                ${rvm_tar_command:-tar} xzf "$1" -C "$2" ${=rvm_tar_options:-};
            else
                ${rvm_tar_command:-tar} xzf "$1" -C "$2" ${rvm_tar_options:-};
            fi
        ;;
        *)
            return 199
        ;;
    esac && __rvm_fix_group_permissions "$2"/* || return $?
}
__rvm_package_list ()
{
    rvm_debug __rvm_package_list:$#: "$@";
    case "$1" in
        *.zip)
            unzip -Z -1 "$1"
        ;;
        *.tar.bz2)
            ${rvm_tar_command:-tar} tjf "$1"
        ;;
        *.tar.gz | *.tgz)
            ${rvm_tar_command:-tar} tzf "$1"
        ;;
        *)
            return 199
        ;;
    esac
}
__rvm_pager_or_cat_v ()
{
    eval "${PAGER:-\cat -v} '$1'"
}
__rvm_parse_args ()
{
    typeset _string;
    export rvm_ruby_string;
    rvm_action="${rvm_action:-""}";
    rvm_parse_break=0;
    if [[ " $* " =~ " --trace " ]]; then
        echo "$@";
        __rvm_version;
    fi;
    while [[ -n "$next_token" ]]; do
        rvm_token="$next_token";
        if (( $# > 0 )); then
            next_token="$1";
            shift;
        else
            next_token="";
        fi;
        case "$rvm_token" in
            [[:alnum:]]* | @*)
                case "$rvm_token" in
                    use)
                        rvm_action="$rvm_token";
                        rvm_verbose_flag=1
                    ;;
                    install | uninstall | reinstall | try_install)
                        export ${rvm_token}_flag=1;
                        rvm_action=$rvm_token
                    ;;
                    gemset)
                        rvm_action=$rvm_token;
                        rvm_ruby_gem_home="${GEM_HOME:-""}";
                        rvm_ruby_args=();
                        __rvm_parse_args_find_known_flags rvm_ruby_args "$next_token" "$@";
                        : rvm_ruby_args:${#rvm_ruby_args[@]}:${rvm_ruby_args[*]}:;
                        next_token="${rvm_ruby_args[__array_start]}";
                        rvm_gemset_name="${rvm_ruby_args[__array_start+1]}";
                        case "${next_token:-help}" in
                            help)
                                true
                            ;;
                            clear)
                                __rvm_gemset_clear
                            ;;
                            use | delete)
                                [[ "delete" != "$next_token" ]] || rvm_delete_flag=1;
                                [[ "use" != "$next_token" ]] || rvm_action+="_$next_token";
                                case "$rvm_gemset_name" in
                                    *${rvm_gemset_separator:-"@"}*)
                                        rvm_ruby_string="${rvm_gemset_name%%${rvm_gemset_separator:-"@"}*}";
                                        rvm_gemset_name="${rvm_gemset_name##*${rvm_gemset_separator:-"@"}}";
                                        if [[ "${rvm_ruby_string:-""}" != "${rvm_gemset_name:-""}" ]]; then
                                            rvm_ruby_string="$rvm_ruby_string${rvm_gemset_separator:-"@"}$rvm_gemset_name";
                                        fi;
                                        rvm_ruby_gem_home="$rvm_ruby_gem_home${rvm_gemset_separator:-"@"}$rvm_gemset_name"
                                    ;;
                                    "")
                                        rvm_error "Gemset was not given.\n  Usage:\n    rvm gemset $rvm_gemset_name <gemsetname>\n";
                                        return 1
                                    ;;
                                esac
                            ;;
                        esac;
                        rvm_parse_break=1
                    ;;
                    gemdir | gempath | gemhome)
                        rvm_ruby_args=("$rvm_token");
                        rvm_action="gemset";
                        rvm_gemdir_flag=1;
                        if [[ "system" == "$next_token" ]]; then
                            rvm_system_flag=1;
                            next_token="${1:-}";
                            (( $# == 0 )) || shift;
                        fi;
                        if [[ "user" == "$next_token" ]]; then
                            rvm_user_flag=1;
                            next_token="${1:-}";
                            (( $# == 0 )) || shift;
                        fi
                    ;;
                    pkg)
                        rvm_action="$rvm_token";
                        __rvm_parse_args_find_known_flags rvm_ruby_args "$next_token" "$@";
                        rvm_parse_break=1
                    ;;
                    do | exec)
                        if [[ -z "$next_token" ]]; then
                            rvm_action="error";
                            rvm_error_message="'rvm $rvm_token' must be followed by arguments.";
                            break;
                        fi;
                        rvm_action="do";
                        rvm_ruby_args=("$next_token" "$@");
                        rvm_parse_break=1
                    ;;
                    gem | rake | ruby)
                        [[ "$rvm_token" == "ruby" ]] && case $rvm_action in
                            install | reinstall | use | remove)
                                rvm_ruby_string=ruby;
                                rvm_ruby_strings=ruby;
                                continue
                            ;;
                        esac;
                        rvm_action=error;
                        rvm_error_message="Please note that \`rvm $rvm_token ...\` was removed, try \`$rvm_token $next_token $*\` or \`rvm all do $rvm_token $next_token $*\` instead."
                    ;;
                    fetch | version | srcdir | reset | debug | reload | update | monitor | notes | implode | seppuku | question | answer | env | unexport | automount | prepare)
                        rvm_action=$rvm_token
                    ;;
                    doctor)
                        rvm_action=notes
                    ;;
                    mount)
                        rvm_action=$rvm_token;
                        while [[ -n "${next_token:-}" ]] && [[ -x "${next_token:-}" || -d "${next_token:-}" || "${next_token:-}" =~ ^http || "${next_token:-}" =~ tar.bz2$ ]]; do
                            rvm_ruby_args=("$next_token" "${rvm_ruby_args[@]}");
                            next_token="${1:-}";
                            (( $# == 0 )) || shift;
                        done
                    ;;
                    rm | remove)
                        rvm_action="remove";
                        rvm_remove_flag=1
                    ;;
                    rtfm | RTFM | rvmrc | usage | help | inspect | list | ls | info | strings | get | current | docs | alias | rubygems | cleanup | tools | disk-usage | snapshot | repair | migrate | downgrade | upgrade | cron | group | switch | which | config-get | requirements | autolibs | osx-ssl-certs | fix-permissions)
                        case "$rvm_token" in
                            downgrade)
                                rvm_action="upgrade"
                            ;;
                            ls)
                                rvm_action="list"
                            ;;
                            usage)
                                rvm_action="help"
                            ;;
                            RTFM)
                                rvm_action="rtfm"
                            ;;
                            *)
                                rvm_action="$rvm_token"
                            ;;
                        esac;
                        rvm_ruby_args=();
                        __rvm_parse_args_find_known_flags rvm_ruby_args "$next_token" "$@";
                        rvm_parse_break=1
                    ;;
                    user)
                        rvm_action="tools";
                        rvm_ruby_args=("$rvm_token" "$next_token" "$@");
                        rvm_parse_break=1
                    ;;
                    load-rvmrc)
                        rvm_action="rvmrc";
                        rvm_ruby_args=("load" "$next_token" "$@");
                        rvm_parse_break=1
                    ;;
                    benchmark | bench)
                        rvm_action="benchmark"
                    ;;
                    specs | tests)
                        rvm_action="rake";
                        rvm_ruby_args=("${rvm_token/%ss/s}")
                    ;;
                    export)
                        if [[ -n "$next_token" ]]; then
                            rvm_export_args="$next_token$@";
                            rvm_action="export";
                            rvm_parse_break=1;
                        else
                            rvm_action="error";
                            rvm_error_message="rvm export must be followed by a NAME=VALUE argument";
                        fi
                    ;;
                    alt*)
                        rvm_action="help";
                        rvm_ruby_args=("alt.md");
                        rvm_parse_break=1
                    ;;
                    wrapper)
                        rvm_action="wrapper";
                        rvm_ruby_string="$next_token";
                        rvm_wrapper_name="$1";
                        (( $# == 0 )) || shift;
                        rvm_ruby_args=("$@");
                        rvm_parse_break=1
                    ;;
                    reboot | damnit | wtf | argh | BOOM | boom | wth)
                        rvm_action="reboot"
                    ;;
                    in)
                        rvm_token="${next_token}";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift;
                        if __rvm_project_dir_check "$rvm_token"; then
                            export rvm_in_flag="$rvm_token";
                            __rvm_rvmrc_tools try_to_read_ruby $rvm_token;
                        else
                            export "rvm_in_flag"=1;
                        fi
                    ;;
                    *,*)
                        rvm_ruby_strings="$rvm_token";
                        [[ -n "${rvm_action:-""}" ]] || rvm_action="ruby"
                    ;;
                    ${rvm_gemset_separator:-"@"}*)
                        rvm_action="${rvm_action:-use}";
                        rvm_gemset_name="${rvm_token/*${rvm_gemset_separator:-"@"}/}";
                        rvm_ruby_string="${rvm_ruby_string:-""}";
                        rvm_ruby_strings="${rvm_ruby_string}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
                    ;;
                    *${rvm_gemset_separator:-"@"}*)
                        rvm_action="${rvm_action:-use}";
                        rvm_gemset_name="${rvm_token/*${rvm_gemset_separator:-"@"}/}";
                        rvm_ruby_string="$rvm_token";
                        rvm_ruby_strings="$rvm_token"
                    ;;
                    *+*)
                        rvm_action="${rvm_action:-use}";
                        rvm_ruby_alias="${rvm_token/*+/}";
                        rvm_ruby_string="${rvm_token/+*/}";
                        rvm_ruby_strings="$rvm_ruby_string"
                    ;;
                    *-* | +([[:digit:]]).+([[:digit:]])*)
                        rvm_action="${rvm_action:-use}";
                        rvm_ruby_string="$rvm_token";
                        rvm_ruby_strings="$rvm_token"
                    ;;
                    opal* | jruby* | ree* | kiji* | macruby* | rbx* | rubinius* | goruby | mruby | ironruby* | default* | maglev* | topaz* | tcs* | jamesgolick* | ruby* | system | default | all)
                        rvm_action="${rvm_action:-use}";
                        case "$rvm_token" in
                            rubinius)
                                rvm_token="rbx"
                            ;;
                        esac;
                        rvm_ruby_interpreter="$rvm_token";
                        rvm_ruby_string="$rvm_token";
                        rvm_ruby_strings="$rvm_token"
                    ;;
                    old)
                        case "${rvm_action:-action-missing}" in
                            remove)
                                rvm_ruby_strings="old:${next_token:-}";
                                next_token="${1:-}";
                                (( $# == 0 )) || shift
                            ;;
                            action-missing)
                                rvm_error_message="what do you want to do with old rubies? rvm can only remove old rubies.";
                                rvm_action="error"
                            ;;
                            *)
                                rvm_error_message="rvm can not $rvm_action old rubies, rvm can only remove old rubies.";
                                rvm_action="error"
                            ;;
                        esac
                    ;;
                    *.rb)
                        rvm_ruby_args=("$rvm_token");
                        rvm_ruby_file="$rvm_token";
                        if [[ -z "${rvm_action:-""}" || "$rvm_action" == "use" ]]; then
                            rvm_action="ruby";
                        fi
                    ;;
                    *.gems)
                        rvm_file_name="${rvm_token}"
                    ;;
                    "")
                        rvm_action="error";
                        rvm_error_message="Unrecognized command line argument(s): '$@'"
                    ;;
                    *)
                        if [[ "gemset" == "$rvm_action" ]]; then
                            rvm_gemset_name="${rvm_token/.gems/}";
                            rvm_file_name="$rvm_gemset_name.gems";
                        else
                            if [[ -f "$rvm_rubies_path/$rvm_token" || -L "$rvm_rubies_path/$rvm_token" ]]; then
                                rvm_ruby_string=$rvm_token;
                                rvm_ruby_strings="$rvm_token";
                                rvm_action="${rvm_action:-use}";
                            else
                                if __rvm_project_dir_check "$rvm_token"; then
                                    __rvm_rvmrc_tools try_to_read_ruby $rvm_token;
                                else
                                    rvm_action="error";
                                    rvm_error_message="Unrecognized command line argument: '$rvm_token'";
                                fi;
                            fi;
                        fi
                    ;;
                esac
            ;;
            -*)
                case "$rvm_token" in
                    -S)
                        rvm_action="ruby";
                        rvm_ruby_args=("$rvm_token" "$next_token" "$@");
                        rvm_parse_break=1
                    ;;
                    -e)
                        rvm_action="ruby";
                        IFS="\n";
                        rvm_ruby_args=("$rvm_token" "'$next_token $@'");
                        IFS=" ";
                        rvm_parse_break=1
                    ;;
                    -v | --version)
                        if [[ -z "$next_token" ]]; then
                            rvm_action="version";
                        else
                            rvm_ruby_version="$next_token";
                            next_token="${1:-}";
                            (( $# == 0 )) || shift;
                        fi
                    ;;
                    -n | --name)
                        rvm_ruby_name="$next_token";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift
                    ;;
                    --branch)
                        rvm_ruby_repo_branch="$next_token";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift;
                        rvm_disable_binary_flag=1
                    ;;
                    --repository | --repo | --url)
                        rvm_ruby_repo_url="$next_token";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift;
                        rvm_disable_binary_flag=1
                    ;;
                    -r | --remote | --binary | --latest-binary)
                        rvm_remote_flag=1;
                        if [[ "$rvm_token" == "--latest-binary" ]]; then
                            rvm_latest_binary_flag=1;
                        fi;
                        while [[ -n "${next_token:-}" ]] && [[ "${next_token:-}" =~ ^http || "${next_token:-}" =~ tar.bz2$ || "${next_token:-}" =~ ":" ]]; do
                            rvm_ruby_args=("${rvm_ruby_args[@]}" "$next_token");
                            next_token="${1:-}";
                            (( $# == 0 )) || shift;
                        done
                    ;;
                    --ree-options)
                        if [[ -n "$next_token" ]]; then
                            __rvm_custom_separated_array rvm_ree_options , "${next_token}";
                            next_token="${1:-}";
                            (( $# == 0 )) || shift;
                        else
                            rvm_action="error";
                            rvm_error_message="--ree-options *must* be followed by... well... comma,separated,list,of,options.";
                        fi
                    ;;
                    --patches | --patch)
                        export -a rvm_patch_names;
                        __rvm_custom_separated_array rvm_patch_names , "$next_token";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift;
                        rvm_patch_original_pwd="$PWD";
                        rvm_disable_binary_flag=1
                    ;;
                    --arch | --archflags)
                        rvm_architectures+=("${next_token#-arch }");
                        next_token="${1:-}";
                        (( $# == 0 )) || shift;
                        rvm_disable_binary_flag=1
                    ;;
                    --with-arch=*)
                        rvm_architectures+=("${rvm_token#--with-arch=}");
                        rvm_disable_binary_flag=1
                    ;;
                    --32 | --64)
                        rvm_architectures+=("${rvm_token#--}");
                        rvm_disable_binary_flag=1
                    ;;
                    --universal)
                        rvm_architectures+=("32" "64");
                        rvm_disable_binary_flag=1
                    ;;
                    --bin)
                        if [[ "update" == "${rvm_action:-""}" ]]; then
                            rvm_bin_flag=1;
                        else
                            rvm_bin_path="$next_token";
                            next_token="${1:-}";
                            (( $# == 0 )) || shift;
                        fi
                    ;;
                    --rdoc | --yard)
                        rvm_docs_type="$rvm_token";
                        rvm_docs_type
                    ;;
                    -f | --file)
                        rvm_action="ruby";
                        rvm_ruby_file="$next_token";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift
                    ;;
                    --passenger)
                        rvm_log "NOTE: If you are using Passenger 3 you no longer need the passenger_ruby,\nuse the wrapper script for your ruby instead (see 'rvm wrapper')";
                        rvm_wrapper_name="${rvm_token/--/}"
                    ;;
                    --editor)
                        rvm_wrapper_name="${rvm_token/--/}"
                    ;;
                    --symlink)
                        rvm_warn "--symlink has been removed, please see 'rvm wrapper'.";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift
                    ;;
                    -h | --help)
                        rvm_action=help
                    ;;
                    -l | --level)
                        rvm_ruby_patch_level="p$next_token";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift
                    ;;
                    --sha | --make | --make-install)
                        rvm_token=${rvm_token#--};
                        rvm_token=${rvm_token//-/_};
                        export "rvm_ruby_${rvm_token}"="$next_token";
                        next_token="${1:-}";
                        rvm_disable_binary_flag=1;
                        (( $# == 0 )) || shift
                    ;;
                    --nice | --sdk | --autoconf-flags | --proxy)
                        rvm_token=${rvm_token#--};
                        rvm_token=${rvm_token//-/_};
                        export "rvm_${rvm_token}"="$next_token";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift
                    ;;
                    --disable-llvm | --disable-jit)
                        rvm_llvm_flag=0
                    ;;
                    --enable-llvm | --enable-jit)
                        rvm_llvm_flag=1
                    ;;
                    --install)
                        rvm_install_on_use_flag=1
                    ;;
                    --autolibs=*)
                        export rvm_autolibs_flag="${rvm_token#*=}"
                    ;;
                    --color=*)
                        rvm_pretty_print_flag=${rvm_token#--color=}
                    ;;
                    --pretty)
                        rvm_pretty_print_flag=auto
                    ;;
                    --1.8 | --1.9 | --2.0 | --18 | --19 | --20)
                        rvm_token=${rvm_token#--};
                        rvm_token=${rvm_token//\./};
                        export "rvm_${rvm_token}_flag"=1;
                        rvm_disable_binary_flag=1
                    ;;
                    --rvmrc | --versions-conf | --ruby-version)
                        rvm_token=${rvm_token#--};
                        rvm_token=${rvm_token//-/_};
                        export rvm_rvmrc_flag="${rvm_token}"
                    ;;
                    --head | --static)
                        rvm_token=${rvm_token#--};
                        rvm_token=${rvm_token//-/_};
                        export "rvm_${rvm_token}_flag"=1
                    ;;
                    --self | --gem | --reconfigure | --default | --force | --export | --summary | --latest | --yaml | --json | --archive | --shebang | --env | --path | --cron | --tail | --delete | --verbose | --import | --sticky | --create | --gems | --docs | --skip-autoreconf | --force-autoconf | --auto-dotfiles | --autoinstall-bundler | --disable-binary | --ignore-gemsets | --skip-gemsets | --debug | --quiet | --silent | --skip-openssl | --fuzzy | --quiet-curl)
                        rvm_token=${rvm_token#--};
                        rvm_token=${rvm_token//-/_};
                        export "rvm_${rvm_token}_flag"=1
                    ;;
                    --auto)
                        export "rvm_auto_dotfiles_flag"=1;
                        rvm_warn "Warning, --auto is deprecated in favor of --auto-dotfiles."
                    ;;
                    --rubygems)
                        rvm_token=${rvm_token#--};
                        rvm_token=${rvm_token//-/_};
                        export "rvm_${rvm_token}_version"="$next_token";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift
                    ;;
                    --dump-environment | --verify-downloads | --max-time)
                        rvm_token=${rvm_token#--};
                        rvm_token=${rvm_token//-/_};
                        export "rvm_${rvm_token}_flag"="$next_token";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift
                    ;;
                    --clang)
                        export CC=clang
                    ;;
                    -M)
                        if [[ -n "$next_token" ]]; then
                            __rvm_custom_separated_array rvm_make_flags , "${next_token}";
                            next_token="${1:-}";
                            (( $# == 0 )) || shift;
                            rvm_disable_binary_flag=1;
                        else
                            rvm_action="error";
                            rvm_error_message="--make *must* be followed by make flags.";
                        fi
                    ;;
                    -j)
                        if [[ -n "$next_token" ]]; then
                            rvm_make_flags+=(-j$next_token);
                            next_token="${1:-}";
                            (( $# == 0 )) || shift;
                        else
                            rvm_action="error";
                            rvm_error_message="-j *must* be followed by an integer (normally the # of CPU's in your machine).";
                        fi
                    ;;
                    --with-rubies)
                        rvm_ruby_strings="$next_token";
                        next_token="${1:-}";
                        (( $# == 0 )) || shift
                    ;;
                    -C | --configure)
                        if [[ -n "$next_token" ]]; then
                            __rvm_custom_separated_array rvm_configure_flags , "${next_token}";
                            next_token="${1:-}";
                            (( $# == 0 )) || shift;
                            rvm_disable_binary_flag=1;
                        else
                            rvm_action="error";
                            rvm_error_message="--configure *must* be followed by configure flags.";
                        fi
                    ;;
                    --movable)
                        rvm_movable_flag=1;
                        rvm_disable_binary_flag=1
                    ;;
                    --with-* | --without-* | --enable-* | --disable-*)
                        rvm_configure_flags+=("$rvm_token");
                        rvm_disable_binary_flag=1
                    ;;
                    --trace)
                        export rvm_trace_flag=1;
                        set -o xtrace;
                        [[ -n "${ZSH_VERSION:-""}" ]] || {
                            set -o errtrace;
                            export PS4="+ \$(date \"+%s.%N\") \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()}  \${LINENO} > "
                        }
                    ;;
                    --)
                        if [[ "${rvm_action}" == *install ]]; then
                            rvm_configure_flags+=("$next_token" "$@");
                        else
                            rvm_ruby_args=("$next_token" "$@");
                        fi;
                        rvm_disable_binary_flag=1;
                        rvm_parse_break=1
                    ;;
                    *)
                        rvm_action="error";
                        rvm_error_message="Unrecognized command line flag: '$rvm_token'"
                    ;;
                esac
            ;;
            *)
                if __rvm_project_dir_check "$rvm_token"; then
                    __rvm_rvmrc_tools try_to_read_ruby "$rvm_token";
                else
                    rvm_action="error";
                    rvm_error_message="Unrecognized command line argument(s): '$rvm_token $@'";
                fi
            ;;
        esac;
        if [[ -z "${rvm_action:-""}" && -n "${rvm_ruby_string:-""}" ]]; then
            rvm_action="use";
        fi;
        if [[ "error" == "${rvm_action:-""}" || ${rvm_parse_break:-0} -eq 1 || -n "${rvm_error_message:-""}" ]]; then
            break;
        fi;
    done;
    : rvm_ruby_args:${#rvm_ruby_args[@]}:${rvm_ruby_args[*]}:;
    if [[ -n "${rvm_error_message:-""}" ]]; then
        rvm_error "$rvm_error_message ( see: 'rvm usage' )";
        unset rvm_error_message;
        return 1;
    fi
}
__rvm_parse_args_find_known_flags ()
{
    typeset _args_array_name _temp_var;
    typeset -a _new_args;
    _args_array_name="$1";
    (( $# == 0 )) || shift;
    _new_args=();
    while (( $# )); do
        case "$1" in
            --verify-downloads)
                export "rvm_verify_downloads_flag"="${2:-}";
                shift
            ;;
            --force | --verbose | --debug | --quiet | --silent | --create)
                export "rvm_${1#--}_flag=1"
            ;;
            --only-path)
                _temp_var="${1#--}";
                export "rvm_${_temp_var//-/_}_flag=1"
            ;;
            --32 | --64)
                rvm_architectures+=("${1#--}");
                rvm_disable_binary_flag=1
            ;;
            --universal)
                rvm_architectures+=("32" "64");
                rvm_disable_binary_flag=1
            ;;
            --patches | --patch)
                export -a rvm_patch_names;
                __rvm_custom_separated_array rvm_patch_names , "${2:-}";
                rvm_patch_original_pwd="$PWD";
                rvm_disable_binary_flag=1;
                shift
            ;;
            --autolibs=*)
                export rvm_autolibs_flag="${1#*=}"
            ;;
            --)
                shift;
                _new_args+=("$@");
                shift $#
            ;;
            *)
                _new_args+=("$1")
            ;;
        esac;
        (( $# == 0 )) || shift;
    done;
    eval "${_args_array_name}+=( \"\${_new_args[@]}\" )"
}
__rvm_path_match_gem_home_check ()
{
    [[ -n "${GEM_HOME:-}" ]] || return 0;
    case "$PATH" in
        $GEM_HOME/bin:*)
            true
        ;;
        *:$GEM_HOME/bin:*)
            __rvm_path_match_gem_home_check_warning "is not at first place"
        ;;
        *)
            __rvm_path_match_gem_home_check_warning "is not available"
        ;;
    esac
}
__rvm_path_match_gem_home_check_warning ()
{
    rvm_warn "Warning! PATH is not properly set up, '$GEM_HOME/bin' $1,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         to fix run: 'rvm use ${GEM_HOME##*/}'."
}
__rvm_project_dir_check ()
{
    typeset _found_file path_to_check variable variable_default;
    typeset -a _valid_files;
    path_to_check="$1";
    variable="${2:-}";
    variable_default="${3:-}";
    _valid_files=("$path_to_check" "$path_to_check/.rvmrc" "$path_to_check/.versions.conf" "$path_to_check/.ruby-version" "$path_to_check/.rbfu-version" "$path_to_check/.rbenv-version" "$path_to_check/Gemfile");
    __rvm_find_first_file _found_file "${_valid_files[@]}" || true;
    if [[ "${_found_file##*/}" == "Gemfile" ]]; then
        [[ -s "$_found_file" ]] && {
            GREP_OPTIONS="" \grep "^#ruby=" "$_found_file" > /dev/null || GREP_OPTIONS="" \grep "^\s*ruby" "$_found_file" > /dev/null
        } || _found_file="";
    fi;
    if [[ -n "$variable" ]]; then
        eval "$variable=\"\${_found_file:-$variable_default}\"";
    fi;
    [[ -n "${_found_file:-$variable_default}" ]] || return $?
}
__rvm_project_rvmrc ()
{
    export __rvm_project_rvmrc_lock;
    : __rvm_project_rvmrc_lock:${__rvm_project_rvmrc_lock:=0};
    : __rvm_project_rvmrc_lock:$((__rvm_project_rvmrc_lock+=1));
    if (( __rvm_project_rvmrc_lock > 1 )); then
        return 0;
    fi;
    typeset working_dir found_file rvm_trustworthiness_result save_PATH;
    working_dir="${1:-"$PWD"}";
    save_PATH="${PATH}";
    while :; do
        if [[ -z "$working_dir" || "$HOME" == "$working_dir" || "${rvm_prefix:-}" == "$working_dir" || "" == "$working_dir" ]]; then
            if [[ -n "${rvm_current_rvmrc:-""}" ]]; then
                __rvm_remove_rvm_from_path;
                __rvm_conditionally_add_bin_path;
                if (( ${rvm_project_rvmrc_default:-0} == 1 )); then
                    __rvm_load_environment "default";
                else
                    if [[ -n "${rvm_previous_environment:-""}" ]]; then
                        __rvm_load_environment "$rvm_previous_environment";
                    fi;
                fi;
                unset rvm_current_rvmrc rvm_previous_environment;
            fi;
            break;
        else
            if __rvm_project_dir_check "$working_dir" found_file; then
                rvm_trustworthiness_result=0;
                if [[ "${rvm_current_rvmrc:-""}" != "${found_file}" ]]; then
                    __rvm_conditionally_do_with_env __rvm_load_project_config "${found_file}" || {
                        rvm_trustworthiness_result=$?;
                        PATH="${save_PATH}"
                    };
                fi;
                unset __rvm_project_rvmrc_lock;
                return "$rvm_trustworthiness_result";
            else
                working_dir="${working_dir%/*}";
            fi;
        fi;
    done;
    unset __rvm_project_rvmrc_lock;
    return 1
}
__rvm_read_lines ()
{
    typeset IFS;
    IFS="
";
    if [[ "${2:--}" == "-" ]]; then
        eval "$1=( \$( \cat - ) )";
    else
        eval "$1=( \$( \cat \"\${2:--}\" ) )";
    fi
}
__rvm_reboot ()
{
    rvm_warn "Do you wish to reboot rvm?\n('yes', or 'no')> ";
    typeset response;
    response="no";
    read response;
    if [[ "yes" == "$response" ]]; then
        __rvm_cd $rvm_path;
        command -v __rvm_reset >> /dev/null 2>&1 || source "$rvm_scripts_path/functions/reset";
        __rvm_reset;
        \mv "$rvm_archives_path" "$HOME/.archives";
        if [[ "/" == "$rvm_path" ]]; then
            rvm_error "remove '/' ?!... NO!";
        else
            if [[ -d "$rvm_path" ]]; then
                __rvm_rm_rf "$rvm_path";
            fi;
        fi;
        gem install rvm $rvm_gem_options;
        "$rvm_scripts_path/get" latest;
        source "$rvm_scripts_path/rvm";
    else
        rvm_log "Carry on then...";
    fi;
    return 0
}
__rvm_record_install ()
{
    [[ -n "$1" ]] || return;
    typeset recorded_ruby_name rvm_install_record_file;
    recorded_ruby_name="$( "$rvm_scripts_path/tools" strings "$1" )";
    rvm_install_record_file="$rvm_user_path/installs";
    [[ -f "$rvm_install_record_file" ]] || \touch "$rvm_install_record_file";
    __rvm_sed_i "$rvm_install_record_file" -e "/^$recorded_ruby_name/d";
    printf "%b" "$recorded_ruby_name -- ${rvm_configure_flags[*]}\n" >> "$rvm_install_record_file"
}
__rvm_record_ruby_configs ()
{
    for dir in "$rvm_path/rubies/"*;
    do
        string=${dir##*/};
        if [[ "${string}" == default ]]; then
            continue;
        fi;
        if [[ -x "${rvm_path}/rubies/${string}/bin/ruby" ]]; then
            if [[ -s "${rvm_path}/rubies/${string}/config" ]]; then
                continue;
            else
                __rvm_ruby_config_save "${rvm_path}/rubies/${string}/bin/ruby";
            fi;
        fi;
    done
}
__rvm_recorded_install_command ()
{
    typeset recorded_ruby_name;
    recorded_ruby_name="$( "$rvm_scripts_path/tools" strings "$1" )";
    recorded_ruby_name=${recorded_ruby_name%%${rvm_gemset_seperator:-"@"}*};
    [[ -n "$recorded_ruby_name" ]] || return 1;
    if [[ -s "$rvm_user_path/installs" ]] && GREP_OPTIONS="" \grep "^$recorded_ruby_name " "$rvm_user_path/installs" > /dev/null 2>&1; then
        GREP_OPTIONS="" \grep "^$recorded_ruby_name " "$rvm_user_path/installs" | head -n 1;
    else
        return 1;
    fi
}
__rvm_remote_extension ()
{
    case "$1" in
        *.tar.*)
            rvm_remote_extension="tar${1##*tar}"
        ;;
        jruby-*)
            rvm_remote_extension="tar.gz"
        ;;
        *)
            rvm_remote_extension="tar.bz2"
        ;;
    esac;
    [[ "$2" != "-" ]] || printf "%b" "${rvm_remote_extension}"
}
__rvm_remote_server_path ()
{
    typeset _iterator;
    _iterator="";
    while ! __rvm_remote_server_path_single 0 1 "${_iterator}" "${1:-}"; do
        : $(( _iterator+=1 ));
    done
}
__rvm_remote_server_path_single ()
{
    typeset __remote_file;
    __rvm_calculate_remote_file "$@" || return $?;
    if [[ -z "${__remote_file:-}" ]]; then
        rvm_debug "No remote file name found";
        return $1;
    else
        if file_exists_at_url "${__remote_file}"; then
            rvm_debug "Found remote file ${__remote_file}";
            printf "%b" "$( __rvm_db "rvm_remote_server_verify_downloads${3:-}" ):${__remote_file}";
        else
            rvm_debug "Remote file does not exist ${__remote_file}";
            return $2;
        fi;
    fi
}
__rvm_remove_from_array ()
{
    typeset _array_name _search _iterator;
    typeset -a _temp_array;
    _array_name="$1";
    _search="$2";
    shift 2;
    _temp_array=();
    for _iterator in "$@";
    do
        __rvm_string_match "$_iterator" "$_search" || _temp_array+=("$_iterator");
    done;
    eval "$_array_name=( \"\${_temp_array[@]}\" )"
}
__rvm_remove_from_path ()
{
    export PATH;
    typeset _value;
    _value="${1//+(\/)//}";
    if [[ "$PATH" =~ "//" ]]; then
        if [[ `uname -s` = "Darwin" ]]; then
            PATH="$(sed -E 's#/+#/#g' <<<$PATH)";
        else
            PATH="$(sed -r 's#/+#/#g' <<<$PATH)";
        fi;
    fi;
    if __rvm_string_match ":$PATH:" "*:${_value}:*"; then
        typeset -a _path;
        _path=();
        __rvm_custom_separated_array _path : "${PATH}";
        __rvm_remove_from_array _path "${_value}" "${_path[@]}";
        __rvm_join_array PATH : _path;
    fi
}
__rvm_remove_install_record ()
{
    typeset recorded_ruby_name rvm_install_record_file;
    recorded_ruby_name="$( "$rvm_scripts_path/tools" strings "$1" )";
    rvm_install_record_file="$rvm_user_path/installs";
    if [[ -s "$rvm_install_record_file" ]]; then
        __rvm_sed_i "$rvm_install_record_file" -e "/^$recorded_ruby_name/d";
    fi
}
__rvm_remove_rvm_from_path ()
{
    typeset local_rvm_path;
    __rvm_remove_from_path "${rvm_path%/}/*";
    __rvm_remove_from_path "${rvm_bin_path}";
    while local_rvm_path="$( __rvm_which rvm 2>/dev/null )"; do
        __rvm_remove_from_path "${local_rvm_path%/*}";
    done;
    builtin hash -r
}
__rvm_reset_rvmrc_trust ()
{
    if [[ "$1" == all ]]; then
        echo "" > "$rvm_user_path/rvmrcs";
    else
        "$rvm_scripts_path/db" "$rvm_user_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "delete" > /dev/null 2>&1;
    fi
}
__rvm_rm_rf ()
{
    __rvm_rm_rf_verbose "$@"
}
__rvm_rm_rf_verbose ()
{
    typeset target;
    target="${1%%+(/|.)}";
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        setopt extendedglob;
    else
        if [[ -n "${BASH_VERSION:-}" ]]; then
            shopt -s extglob;
        else
            rvm_error "What the heck kind of shell are you running here???";
        fi;
    fi;
    case "${target}" in
        *(/|.)@(|/Applications|/Developer|/Guides|/Information|/Library|/Network|/System|/User|/Users|/Volumes|/backups|/bdsm|/bin|/boot|/cores|/data|/dev|/etc|/home|/lib|/lib64|/mach_kernel|/media|/misc|/mnt|/net|/opt|/private|/proc|/root|/sbin|/selinux|/srv|/sys|/tmp|/usr|/var))
            rvm_debug "__rvm_rm_rf target is not valid - can not remove";
            return 1
        ;;
        *)
            [[ -n "${target}" ]] || {
                rvm_debug "__rvm_rm_rf target not given";
                return 1
            };
            if [[ -d "${target}" ]]; then
                \rm -rf "${target}" || {
                    typeset ret=$?;
                    rvm_debug "__rvm_rm_rf error removing target dir '${target}'.";
                    return $ret
                };
            else
                if [[ -f "${target}" || -L "${target}" ]]; then
                    \rm -f "${target}" || {
                        typeset ret=$?;
                        rvm_debug "__rvm_rm_rf error removing target file/link '${target}'.";
                        return $ret
                    };
                else
                    rvm_debug "__rvm_rm_rf already gone: $*";
                    return 0;
                fi;
            fi
        ;;
    esac
}
__rvm_ruby_config_get ()
{
    typeset variable_name ruby_path;
    variable_name="$1";
    ruby_path="${2:-$rvm_ruby_home/bin/ruby}";
    case "${variable_name:---all}" in
        --all)
            "$ruby_path" -rrbconfig -e 'puts RbConfig::CONFIG.sort.map{|k,v| "#{k}: #{v}" }' 2> /dev/null
        ;;
        *)
            "$ruby_path" -rrbconfig -e 'puts RbConfig::CONFIG["'"$variable_name"'"]' 2> /dev/null
        ;;
    esac
}
__rvm_ruby_config_save ()
{
    typeset ruby_path config_path default_config_path;
    ruby_path="${1:-$rvm_ruby_home/bin/ruby}";
    default_config_path="#{RbConfig::CONFIG[\"prefix\"]}/config";
    config_path="${2:-$default_config_path}";
    "$ruby_path" -rrbconfig -e '\
    File.open("'"$config_path"'","w") { |file|
      RbConfig::CONFIG.sort.each{|key,value|
        file.write("#{key.gsub(/\.|-/,"_")}=\"#{value.gsub("$","\\$")}\"\n")
      }
    }
  ' > /dev/null 2>&1
}
__rvm_ruby_package_file ()
{
    case "$1" in
        *.tar.*)
            rvm_ruby_package_file="/$1"
        ;;
        rbx-*)
            rvm_ruby_package_file="/${1//rbx-/rubinius-}.$(__rvm_remote_extension "$1" -)"
        ;;
        jruby-*)
            typeset __version;
            __version="$(
        rvm_ruby_string="$1"
        __rvm_ruby_string
        echo "$rvm_ruby_version"
      )";
            rvm_ruby_package_file="/${__version}/jruby-bin-${__version}.$(__rvm_remote_extension "$1" -)"
        ;;
        "")
            rvm_ruby_package_file=""
        ;;
        *)
            rvm_ruby_package_file="/$1.$(__rvm_remote_extension "$1" -)"
        ;;
    esac
}
__rvm_ruby_string ()
{
    typeset ruby_string gemset_name expanded_alias_name repo_url branch_name ruby_name;
    __rvm_default_flags;
    rvm_expanding_aliases=;
    true "${rvm_ruby_version:=}" "${rvm_gemset_name:=}" "${rvm_ruby_interpreter:=}" "${rvm_ruby_version:=}" "${rvm_ruby_tag:=}" "${rvm_ruby_patch_level:=}" "${rvm_ruby_revision:=}" ${rvm_gemset_separator:="@"} "${rvm_ruby_string:=}" ${rvm_expanding_aliases:=0} ${rvm_head_flag:=0};
    if echo "$rvm_ruby_string" | GREP_OPTIONS="" \grep "${rvm_gemset_separator}" > /dev/null 2>&1; then
        rvm_gemset_name="${rvm_ruby_string/*${rvm_gemset_separator}/}";
        rvm_ruby_string="${rvm_ruby_string/${rvm_gemset_separator}*/}";
    fi;
    if (( rvm_expanding_aliases == 0 )) && [[ -n "${rvm_ruby_string}" && "$rvm_ruby_string" != "system" ]]; then
        if [[ -f "$rvm_path/config/alias" && -s "$rvm_path/config/alias" ]] && expanded_alias_name="$("$rvm_scripts_path"/db "$rvm_path/config/alias" "$rvm_ruby_string")" && [[ -n "$expanded_alias_name" ]]; then
            rvm_ruby_string="$expanded_alias_name";
        else
            if [[ "$rvm_ruby_string" == default ]]; then
                rvm_ruby_string="system";
            fi;
        fi;
    fi;
    if echo "$rvm_ruby_string" | GREP_OPTIONS="" \grep "${rvm_gemset_separator}" > /dev/null 2>&1; then
        rvm_gemset_name="${rvm_ruby_string/*${rvm_gemset_separator}/}";
        rvm_ruby_string="${rvm_ruby_string/${rvm_gemset_separator}*/}";
    fi;
    ruby_string="${rvm_ruby_string:-}";
    gemset_name="${rvm_gemset_name:-}";
    repo_url="${rvm_ruby_repo_url:-}";
    branch_name="${rvm_ruby_repo_branch:-}";
    ruby_name="${rvm_ruby_name:-}";
    __rvm_unset_ruby_variables;
    rvm_ruby_repo_url="${repo_url:-}";
    rvm_ruby_repo_branch="${branch_name:-}";
    rvm_ruby_name="$ruby_name";
    if [[ -n "$gemset_name" ]]; then
        rvm_gemset_name="$gemset_name";
        rvm_sticky_flag=1;
    fi;
    strings=();
    __rvm_custom_separated_array strings - "${ruby_string}";
    if (( ${#strings[@]} == 0 )); then
        if echo "${GEM_HOME:-}" | GREP_OPTIONS="" \grep "${rvm_gems_path}" > /dev/null 2>&1; then
            strings="${GEM_HOME##*\/}";
            strings="${strings/%${rvm_gemset_separator:-"@"}*}";
            rvm_ruby_string="$strings";
            strings=($(echo ${rvm_ruby_string//-/ }));
        else
            strings=(system);
            rvm_ruby_string="system";
        fi;
    fi;
    for string in ${strings[@]};
    do
        case "$string" in
            head)
                rvm_ruby_patch_level="";
                rvm_ruby_revision="";
                rvm_ruby_tag="";
                export rvm_head_flag=1
            ;;
            system)
                rvm_ruby_interpreter="system";
                rvm_ruby_patch_level="";
                rvm_ruby_tag="";
                rvm_ruby_revision="";
                rvm_ruby_version="";
                rvm_gemset_name="";
                rvm_head_flag=0;
                return 0
            ;;
            ext | external)
                rvm_ruby_interpreter="ext";
                rvm_ruby_patch_level="";
                rvm_ruby_tag="";
                rvm_ruby_revision="";
                rvm_ruby_version="";
                rvm_head_flag=0;
                rvm_ruby_name="${ruby_string:-${rvm_ruby_string}}";
                rvm_ruby_name="${rvm_ruby_name#*-}";
                break
            ;;
            nightly | weekly | monthly)
                case "${rvm_ruby_interpreter}" in
                    rbx | rubinius)
                        rvm_ruby_patch_level="$string"
                    ;;
                    *)
                        rvm_ruby_version="$string"
                    ;;
                esac;
                rvm_nightly_flag=1
            ;;
            nightly* | weekly* | monthly*)
                case "${rvm_ruby_interpreter}" in
                    rbx | rubinius)
                        rvm_ruby_patch_level="$string"
                    ;;
                    *)
                        rvm_ruby_version="$string"
                    ;;
                esac
            ;;
            preview*)
                rvm_ruby_patch_level="$string"
            ;;
            rc[[:digit:]]*)
                rvm_ruby_patch_level="$string"
            ;;
            [[:digit:]].[[:digit:]]* | [[:digit:]][[:digit:]].[[:digit:]]*)
                if [[ "${rvm_ruby_interpreter}" == "rbx" ]]; then
                    if [[ -z "${rvm_ruby_version}" ]]; then
                        rvm_ruby_version="${string}";
                    else
                        if [[ -z "${rvm_ruby_patch_level}" ]]; then
                            rvm_ruby_patch_level="${string}";
                        else
                            rvm_error "Unknown ruby interpreter string component: '$string'.";
                            return 1;
                        fi;
                    fi;
                else
                    case "$string" in
                        1.8)
                            rvm_ruby_version="$string.7";
                            rvm_ruby_revision="";
                            rvm_ruby_tag=""
                        ;;
                        1.9)
                            rvm_ruby_version="$string.3";
                            rvm_ruby_revision="";
                            rvm_ruby_tag=""
                        ;;
                        2.0)
                            rvm_ruby_version="$string.0";
                            rvm_ruby_revision="";
                            rvm_ruby_tag=""
                        ;;
                        0.+([[:digit:]]) | 0.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]) | 2.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]))
                            rvm_ruby_version="$string";
                            rvm_ruby_revision="";
                            rvm_ruby_tag=""
                        ;;
                        1.+([[:digit:]]).+([[:digit:]]).+([[:alnum:]]))
                            case "${rvm_ruby_interpreter:-""}" in
                                jruby)
                                    rvm_ruby_version="$string"
                                ;;
                                *)
                                    rvm_error "Unknown ruby interpreter version: '$string'.";
                                    return 1
                                ;;
                            esac
                        ;;
                        *)
                            rvm_error "Unknown ruby interpreter version: '$string'.";
                            return 1
                        ;;
                    esac;
                fi
            ;;
            p[[:digit:]]*)
                rvm_ruby_patch_level="$string"
            ;;
            [[:digit:]][[:digit:]]*)
                case "${rvm_ruby_interpreter:-""}" in
                    ree)
                        rvm_ruby_patch_level="$string";
                        rvm_ruby_revision=""
                    ;;
                    kiji)
                        rvm_ruby_patch_level="$string";
                        rvm_ruby_revision=""
                    ;;
                    rbx)
                        rvm_ruby_patch_level="$string"
                    ;;
                    maglev)
                        rvm_ruby_version="$string";
                        rvm_ruby_revision="";
                        rvm_ruby_patch_level=""
                    ;;
                    *)
                        rvm_ruby_revision="r$string"
                    ;;
                esac
            ;;
            r[[:digit:]]*)
                rvm_ruby_patch_level="";
                rvm_ruby_revision="$string"
            ;;
            s[[:alnum:]]*)
                rvm_ruby_revision="";
                rvm_ruby_sha="${string#s}"
            ;;
            tv[[:digit:]]* | t[[:digit:]]*)
                rvm_ruby_patch_level="";
                rvm_ruby_revision="";
                rvm_ruby_tag="$string"
            ;;
            m[[:digit:]]*)
                rvm_ruby_mode="$string"
            ;;
            u[[:alnum:]]*)
                rvm_ruby_patch_level="";
                rvm_ruby_revision="";
                rvm_ruby_tag="";
                rvm_ruby_patch="";
                rvm_ruby_user_tag="$string"
            ;;
            a[[:digit:]][[:digit:]]*)
                rvm_ruby_bits="$string"
            ;;
            b[[:digit:]]*)
                rvm_ruby_repo_branch="${string}";
                rvm_head_flag=1
            ;;
            opal | ruby | rbx | jruby | macruby | ree | kiji | rubinius | maglev | ironruby | goruby | mruby | tcs | jamesgolick | topaz)
                rvm_ruby_interpreter="$string"
            ;;
            [[:alpha:]]*([[:alnum:]]|_))
                rvm_ruby_name="$string"
            ;;
            *)
                rvm_error "Unknown ruby interpreter string component: '$string'.";
                return 1
            ;;
        esac;
    done;
    if [[ -z "${rvm_ruby_interpreter:-""}" ]]; then
        case "$rvm_ruby_version" in
            0.[5-6]*)
                rvm_ruby_interpreter="macruby"
            ;;
            1.[0-4]*)
                rvm_ruby_interpreter="rbx"
            ;;
            1.[5-7]*)
                rvm_ruby_interpreter="jruby"
            ;;
            1.[8-9]*)
                rvm_ruby_interpreter="ruby"
            ;;
            2.*)
                rvm_ruby_interpreter="ruby"
            ;;
        esac;
    fi;
    rvm_ruby_version="${rvm_ruby_version:-}";
    if [[ -z "${rvm_ruby_version:-}" && "${rvm_ruby_interpreter}" != "ext" ]] && (( ${rvm_head_flag:=0} == 0 )); then
        if (( ${rvm_fuzzy_flag:-0} == 1 )); then
            rvm_ruby_version="$(
        "${rvm_scripts_path:-$rvm_path/scripts}/list" strings |
          \grep "^${rvm_ruby_interpreter}-.*${rvm_ruby_name:-}" |
          awk -F- '{print $2}' | sort | tail -n 1
      )";
        fi;
        rvm_ruby_version="${rvm_ruby_version:-"$(
    __rvm_db "${rvm_ruby_interpreter}_version"
    )"}";
    fi;
    rvm_ruby_string="${rvm_ruby_interpreter}${rvm_ruby_version:+-}${rvm_ruby_version:-}";
    if [[ "${rvm_ruby_interpreter}" == "ext" ]]; then
        true;
    else
        if [[ "${rvm_head_flag:=0}" == "1" || -n "${rvm_ruby_sha:-}" || -n "${rvm_ruby_tag:-}" ]]; then
            if [[ "${rvm_head_flag:=0}" == "1" ]]; then
                rvm_ruby_string="${rvm_ruby_string}-head";
            fi;
            if [[ -n "${rvm_ruby_sha:-}" ]]; then
                rvm_ruby_string="${rvm_ruby_string}-s${rvm_ruby_sha}";
            else
                if [[ -n "${rvm_ruby_tag:-}" ]]; then
                    rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_tag}";
                fi;
            fi;
            if [[ ! -d "${rvm_rubies_path}/${rvm_ruby_string}" ]] && (( ${rvm_fuzzy_flag:-0} == 1 )); then
                rvm_ruby_string="$(
        "${rvm_scripts_path:-$rvm_path/scripts}/list" strings |
          \grep "^${rvm_ruby_string}.*${rvm_ruby_name:-}" |
          sort | tail -n 1
      )";
            fi;
        else
            if [[ -n "${rvm_ruby_revision:-}" ]]; then
                rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_revision}";
            else
                if [[ -n "${rvm_ruby_patch_level:-}" ]]; then
                    rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_patch_level}";
                else
                    if [[ -n "${rvm_ruby_user_tag:-}" ]]; then
                        rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_user_tag}";
                    else
                        if (( ${rvm_fuzzy_flag:-0} == 1 )) && [[ "${rvm_ruby_interpreter}" == "ruby" || "${rvm_ruby_interpreter}" == "ree" ]]; then
                            rvm_ruby_patch_level="$(
        "${rvm_scripts_path:-$rvm_path/scripts}/list" strings |
          \grep "^${rvm_ruby_interpreter}-${rvm_ruby_version}-.*${rvm_ruby_name:-}" |
          awk -F- '{print $3}' | sort | tail -n 1
      )";
                        fi;
                        if (( ${rvm_latest_binary_flag:-0} == 1 )) && [[ "${rvm_ruby_interpreter}" == "ruby" || "${rvm_ruby_interpreter}" == "ree" ]]; then
                            rvm_ruby_patch_level="$(
        __list_remote_rubies_for $( __rvm_system_path_for rubies ) |
          awk -F/ '{x=$NF; gsub(".tar.*","",x); print x}' |
          \grep "${rvm_ruby_interpreter}-${rvm_ruby_version}-" |
          awk -F- '{print $3}' | sort | tail -n 1
      )";
                        fi;
                        [[ -n "${rvm_ruby_patch_level:-""}" ]] || rvm_ruby_patch_level="$(
      __rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_patch_level"
    )";
                        if [[ -n "${rvm_ruby_patch_level:-""}" ]]; then
                            rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_patch_level}";
                        fi;
                    fi;
                fi;
            fi;
        fi;
    fi;
    if [[ -n "${rvm_ruby_name:-}" ]]; then
        rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_name}";
        detected_rvm_ruby_name="${rvm_ruby_name}";
        rvm_ruby_name="";
    else
        detected_rvm_ruby_name="";
    fi;
    true
}
__rvm_ruby_string_paths_under ()
{
    typeset __search_path part parts IFS;
    IFS=" ";
    __search_path="${1%/}";
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        parts=(${=rvm_ruby_string//-/ });
    else
        parts=(${rvm_ruby_string//-/ });
    fi;
    echo "$__search_path";
    for part in "${parts[@]}";
    do
        __search_path="$__search_path/$part";
        echo "$__search_path";
    done
}
__rvm_ruby_strings_exist ()
{
    for rvm_ruby_string in ${@//,/ };
    do
        rvm_gemset_name="";
        rvm_verbose_flag=0 __rvm_use "${rvm_ruby_string}" > /dev/null 2>&1 || return $?;
        printf "%b" "${rvm_ruby_string}${rvm_gemset_name:+@}${rvm_gemset_name:-}\n";
    done;
    unset rvm_ruby_string
}
__rvm_rubygems_create_link ()
{
    \mkdir -p "$rvm_ruby_gem_home" "$rvm_ruby_global_gems_path";
    typeset ruby_lib_gem_path;
    rubygems_detect_ruby_lib_gem_path "${1:-ruby}" || return 0;
    \mkdir -p "$(dirname $ruby_lib_gem_path)";
    if [[ -d "$ruby_lib_gem_path" && ! -L "$ruby_lib_gem_path" ]]; then
        if [[ "$rvm_ruby_gem_home" != "$rvm_ruby_global_gems_path" ]]; then
            \cp -f "$ruby_lib_gem_path"/* "$rvm_ruby_global_gems_path"/ 2> /dev/null;
        fi;
        \mv -f "$ruby_lib_gem_path"/* "$rvm_ruby_gem_home"/ 2> /dev/null;
    fi;
    __rvm_rm_rf "$ruby_lib_gem_path";
    ln -fs "$rvm_ruby_gem_home" "$ruby_lib_gem_path"
}
__rvm_run ()
{
    typeset name message;
    typeset -a _command_array;
    name="${1:-}";
    eval "_command_array=( ${2:-} )";
    message="${3:-}";
    __rvm_log_command "$name" "$message" "${_command_array[@]}" || return $?
}
__rvm_run_script ()
{
    "$rvm_scripts_path/${1:-"$rvm_action"}" "${rvm_ruby_args[@]}"
}
__rvm_run_wrapper ()
{
    ( file="$1";
    action="${2:-}";
    shift 2;
    rubies_string="${1:-}";
    export -a args;
    args=($@);
    source "$rvm_scripts_path"/$file )
}
__rvm_rvmrc_key ()
{
    printf "%b" "$1" | \tr '[#/.=()]' _;
    return $?
}
__rvm_rvmrc_match_all ()
{
    [[ "${1:-}" == "all" || "${1:-}" == "all.rvmrcs" || "${1:-}" == "allGemfiles" ]]
}
__rvm_rvmrc_stored_trust ()
{
    [[ -f "$1" ]] || return 1;
    "${rvm_scripts_path:-"$rvm_path/scripts"}/db" "$rvm_user_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" || return $?
}
__rvm_rvmrc_stored_trust_check ()
{
    typeset _first _second rvmrc_path;
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        _first=1;
    else
        _first=0;
    fi;
    _second=$(( _first + 1 ));
    rvmrc_path="$1";
    if [[ -f "$rvmrc_path" ]]; then
        saveIFS=$IFS;
        IFS=';';
        trust=($(__rvm_rvmrc_stored_trust "$rvmrc_path"));
        IFS=$saveIFS;
        if [[ "${trust[${_second}]:-'#'}" != "$(__rvm_checksum_for_contents "$rvmrc_path")" ]]; then
            echo "The rvmrc at '$rvmrc_path' contains unreviewed changes.";
            return 1;
        else
            if [[ "${trust[${_first}]}" == '1' ]]; then
                echo "The rvmrc at '$rvmrc_path' is currently trusted.";
                return 0;
            else
                if [[ "${trust[${_first}]}" == '0' ]]; then
                    echo "The rvmrc at '$rvmrc_path' is currently untrusted.";
                    return 1;
                else
                    echo "The trustiworthiness of '$rvmrc_path' is currently unknown.";
                    return 1;
                fi;
            fi;
        fi;
    else
        echo "There is no $rvmrc_path";
        return 1;
    fi
}
__rvm_rvmrc_to ()
{
    case "${1:-help}" in
        .ruby-version | ruby-version)
            __rvm_rvmrc_to_ruby_version || return $?
        ;;
        help)
            rvm_help rvmrc to;
            return 0
        ;;
        *)
            rvm_error_help "Unknown subcommand '$1'" rvmrc to;
            return 1
        ;;
    esac
}
__rvm_rvmrc_to_ruby_version ()
{
    ( [[ -s "$PWD/.rvmrc" ]] || {
        rvm_error "No .rvmrc to convert";
        return 2
    };
    __rvm_load_project_config "$PWD/.rvmrc" || {
        rvm_error "Could not load .rvmrc";
        return 3
    };
    __rvm_set_ruby_version;
    \rm .rvmrc || {
        rvm_error "Could not remove .rvmrc";
        return 4
    } )
}
__rvm_rvmrc_tools ()
{
    typeset rvmrc_action rvmrc_warning_action rvmrc_path saveIFS trust rvmrc_ruby;
    rvmrc_action="$1";
    (( $# )) && shift || true;
    if [[ "${rvmrc_action}" == "warning" ]]; then
        rvmrc_warning_action="${1:-}";
        (( $# )) && shift || true;
    fi;
    if [[ "${rvmrc_action}" == "create" ]]; then
        rvmrc_ruby="${1:-${GEM_HOME##*/}}";
        rvmrc_path="$(__rvm_cd "$PWD" >/dev/null 2>&1; pwd)";
    else
        if [[ "${rvmrc_action}" == "to" ]]; then
            rvmrc_path="$1";
        else
            if __rvm_rvmrc_match_all "${1:-}"; then
                rvmrc_path="$1";
            else
                if [[ -n "${1:-}" ]]; then
                    rvmrc_path="${1%/.rvmrc}";
                else
                    rvmrc_path="$PWD";
                fi;
                rvmrc_path="$(__rvm_cd "${rvmrc_path}" >/dev/null 2>&1; pwd)";
            fi;
        fi;
    fi;
    (( $# )) && shift || true;
    if (( $# )); then
        rvmrc_path="${rvmrc_path}/$1";
    else
        if [[ "${rvmrc_action}" == "to" ]] || __rvm_rvmrc_match_all "${rvmrc_path:-}"; then
            true;
        else
            __rvm_project_dir_check "${rvmrc_path}" rvmrc_path "${rvmrc_path}/.rvmrc";
        fi;
    fi;
    case "$rvmrc_action" in
        warning)
            __rvmrc_warning "${rvmrc_warning_action:-}" "$rvmrc_path" || return $?
        ;;
        to)
            __rvm_rvmrc_to "$rvmrc_path" || return $?
        ;;
        create)
            ( rvm_create_flag=1 __rvm_use "${rvmrc_ruby}";
            case "${rvmrc_path}" in
                */.rvmrc | */--rvmrc)
                    __rvm_set_rvmrc
                ;;
                */.ruby-version | */--ruby-version)
                    __rvm_set_ruby_version
                ;;
                */.versions.conf | */--versions-conf)
                    __rvm_set_versions_conf
                ;;
                *)
                    rvm_error "Unrecognized project file format.";
                    return 1
                ;;
            esac )
        ;;
        reset)
            __rvm_reset_rvmrc_trust "$rvmrc_path" && rvm_log "Reset trust for $rvmrc_path" || rvm_error "Reset trust for $rvmrc_path - failed"
        ;;
        trust)
            __rvm_trust_rvmrc "$rvmrc_path" && rvm_log "Marked $rvmrc_path as trusted" || rvm_error "Marked $rvmrc_path as trusted - failed"
        ;;
        untrust)
            __rvm_untrust_rvmrc "$rvmrc_path" && rvm_log "Marked $rvmrc_path as untrusted" || rvm_error "Marked $rvmrc_path as untrusted - failed"
        ;;
        trusted)
            __rvm_rvmrc_stored_trust_check "$rvmrc_path" || return $?
        ;;
        is_trusted)
            __rvm_rvmrc_stored_trust_check "$rvmrc_path" > /dev/null
        ;;
        load)
            rvm_current_rvmrc="" rvm_trust_rvmrcs_flag=1 __rvm_project_rvmrc "$rvmrc_path"
        ;;
        try_to_read_ruby)
            case "$rvmrc_path" in
                */.rvmrc)
                    if ! __rvm_rvmrc_tools is_trusted "$(dirname "$rvmrc_path")" "$(basename "$rvmrc_path")"; then
                        ( rvm_promptless=1 __rvm_project_rvmrc "$rvmrc_path" > /dev/null 2>&1 );
                    fi;
                    if __rvm_rvmrc_tools is_trusted "$(dirname "$rvmrc_path")" "$(basename "$rvmrc_path")"; then
                        rvm_action="${rvm_action:-use}";
                        rvm_ruby_string="$(
              rvm_current_rvmrc=""
              rvm_trust_rvmrcs_flag=1
              rvm_is_not_a_shell_function=0
              __rvm_project_rvmrc "$rvmrc_path" >/dev/null 2>&1
              __rvm_env_string
            )";
                        rvm_ruby_strings="$rvm_ruby_string";
                    else
                        rvm_action="error";
                        rvm_error_message="The give path does not contain '$(basename "$rvmrc_path")' (or it is not trusted): '$(dirname "$rvmrc_path")' rest of params: '$@'";
                    fi
                ;;
                *)
                    rvm_action="${rvm_action:-use}";
                    rvm_ruby_string="$(
            rvm_current_rvmrc=""
            rvm_trust_rvmrcs_flag=1
            __rvm_project_rvmrc "$rvmrc_path" >/dev/null 2>&1
            __rvm_env_string
          )";
                    rvm_ruby_strings="$rvm_ruby_string"
                ;;
            esac
        ;;
        *)
            rvm_error "Usage: rvm rvmrc {trust,untrust,trusted,load,reset,is_trusted,try_to_read_ruby,create}";
            return 1
        ;;
    esac;
    return $?
}
__rvm_sed_i ()
{
    typeset _filename _executable;
    [[ -n "${1:-}" ]] || {
        rvm_debug "no file given for __rvm_sed_i";
        return 0
    };
    _filename="$1";
    shift;
    if [[ -x "${_filename}" ]]; then
        _executable=true;
    fi;
    {
        \sed "$@" < "${_filename}" > "${_filename}.new" && \mv -f "${_filename}.new" "${_filename}"
    } 2>&1 | rvm_debug_stream;
    if [[ -n "${_executable:-}" ]]; then
        chmod +x "${_filename}";
    fi
}
__rvm_select ()
{
    true ${rvm_gemset_name:=};
    typeset _original_env_string;
    _original_env_string=${rvm_env_string};
    export -a rvm_configure_flags rvm_patch_names rvm_ree_options rvm_make_flags;
    export GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION IRBRC;
    export rvm_env_string rvm_action rvm_alias_expanded rvm_archive_extension rvm_bin_flag rvm_bin_path rvm_debug_flag rvm_default_flag rvm_delete_flag rvm_docs_type rvm_dump_environment_flag rvm_error_message rvm_expanding_aliases rvm_file_name rvm_gemdir_flag rvm_gemset_name rvm_gemstone_package_file rvm_gemstone_url rvm_head_flag rvm_hook rvm_install_on_use_flag rvm_llvm_flag rvm_loaded_flag rvm_niceness rvm_nightly_flag rvm_only_path_flag rvm_parse_break rvm_patch_original_pwd rvm_pretty_print_flag rvm_proxy rvm_quiet_flag rvm_reload_flag rvm_remove_flag rvm_ruby_alias rvm_ruby_args rvm_ruby_binary rvm_ruby_bits rvm_ruby_configure rvm_ruby_file rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_global_gems_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_major_version rvm_ruby_make rvm_ruby_make_install rvm_ruby_minor_version rvm_ruby_mode rvm_ruby_name rvm_ruby_package_file rvm_ruby_package_name rvm_ruby_patch rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_sha rvm_ruby_string rvm_ruby_strings rvm_ruby_tag rvm_ruby_url rvm_ruby_user_tag rvm_ruby_version rvm_script_name rvm_sdk rvm_silent_flag rvm_sticky_flag rvm_system_flag rvm_token rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_wrapper_name;
    rvm_ruby_string="${1:-${rvm_ruby_string:-}}";
    if [[ -z "${rvm_ruby_string:-}" ]]; then
        rvm_ruby_string="${rvm_ruby_interpreter:-}";
        rvm_ruby_string="${rvm_ruby_string:-}${rvm_ruby_version:+-}${rvm_ruby_version:-}";
        rvm_ruby_string="${rvm_ruby_string:-}${rvm_ruby_patch_level:+-}${rvm_ruby_patch_level:-}";
        rvm_ruby_string="${rvm_ruby_string:-}${rvm_ruby_revision:+-}${rvm_ruby_revision:-}";
        if [[ -n "${rvm_ruby_name:-}" ]]; then
            rvm_ruby_name="$rvm_ruby_string-$rvm_ruby_name";
        fi;
    fi;
    __rvm_ruby_string || return $?;
    rvm_archive_extension="tar.gz";
    if [[ -z "${rvm_ruby_interpreter:-}" ]]; then
        rvm_ruby_interpreter="${rvm_ruby_string//-*/}";
    fi;
    case "${rvm_ruby_interpreter:-missing}" in
        missing)
            return 2
        ;;
        opal)
            rvm_ruby_version="head";
            rvm_ruby_revision="head";
            rvm_ruby_interpreter="opal";
            rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "jruby_repo_url")}";
            rvm_ruby_url="${rvm_ruby_repo_url:-$(__rvm_db "jruby_repo_url")}";
            rvm_disable_binary_flag=1
        ;;
        topaz)
            rvm_ruby_version="head";
            rvm_ruby_revision="head";
            rvm_ruby_interpreter="topaz";
            rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "topaz_repo_url")}";
            rvm_ruby_url="${rvm_ruby_url:-$(__rvm_db "topaz_url")}";
            rvm_disable_binary_flag=1
        ;;
        macruby)
            if [[ "Darwin" == "$(uname)" ]]; then
                rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}";
                if (( ${rvm_head_flag:=0} == 1 )); then
                    rvm_ruby_version="";
                    rvm_ruby_tag="";
                    rvm_ruby_revision="head";
                    __rvm_db "macruby_repo_url" "rvm_ruby_repo_url";
                    rvm_ruby_url="$rvm_ruby_repo_url";
                    rvm_disable_binary_flag=1;
                else
                    if [[ "${rvm_ruby_version:-}" =~ "nightly" ]]; then
                        __rvm_select_macruby_nightly;
                    else
                        if [[ -n "${rvm_ruby_version:-}" ]]; then
                            __rvm_db "macruby_${rvm_ruby_version}_url" "rvm_ruby_url";
                            [[ -n "${rvm_ruby_url:-}" ]] || __rvm_db "macruby_url" "rvm_ruby_url";
                            rvm_ruby_package_name="MacRuby%20${rvm_ruby_version}.zip";
                            rvm_ruby_package_file="$rvm_ruby_package_name";
                            rvm_ruby_url="$rvm_ruby_url/$rvm_ruby_package_name";
                        else
                            __rvm_db "macruby_version" "rvm_ruby_version";
                            __rvm_db "macruby_url" "rvm_ruby_url";
                            rvm_ruby_package_name="MacRuby%20${rvm_ruby_version}.zip";
                            rvm_ruby_package_file="$rvm_ruby_package_name";
                            rvm_ruby_url="$rvm_ruby_url/$rvm_ruby_package_name";
                        fi;
                    fi;
                fi;
                rvm_ruby_patch_level="";
            else
                rvm_error "MacRuby can only be installed on a Darwin OS.";
            fi
        ;;
        rbx | rubinius)
            __rvm_select_rbx_nightly || return $?;
            rvm_archive_extension="tar.gz";
            rvm_ruby_interpreter="rbx";
            rvm_ruby_version=${rvm_ruby_version:-$(__rvm_db "rbx_version")};
            rvm_ruby_repo_url=${rvm_rbx_repo_url:-$(__rvm_db "rubinius_repo_url")};
            rbx_url=${rbx_url:-$(__rvm_db "rbx_url")};
            case "${rvm_ruby_version}" in
                2.0pre)
                    rvm_ruby_repo_branch="master"
                ;;
                2.0.testing)
                    rvm_ruby_repo_branch="${rvm_ruby_version}"
                ;;
            esac;
            if (( ${rvm_head_flag:=0} == 0 )); then
                if [[ -n "${rvm_ruby_patch_level:-}" ]]; then
                    rbx_url="$( __rvm_db "rbx_2.0.0_url" )";
                    rvm_archive_extension="zip";
                    rvm_ruby_url="${rbx_url}";
                    rvm_ruby_package_file="release-${rvm_ruby_version}-${rvm_ruby_patch_level}.${rvm_archive_extension}";
                    rvm_ruby_url="$rvm_ruby_url/$rvm_ruby_package_file";
                else
                    rvm_ruby_patch_level="";
                    rvm_ruby_url="${rbx_url}";
                    rvm_ruby_package_file="rubinius-${rvm_ruby_version}.${rvm_archive_extension}";
                    rvm_ruby_url="$rvm_ruby_url/$rvm_ruby_package_file";
                fi;
            else
                rvm_ruby_patch_level="";
                rvm_ruby_version="head";
                rvm_disable_binary_flag=1;
            fi;
            if [[ -n "${rvm_rbx_opt:-}" ]]; then
                export RBXOPT="${RBXOPT:=${rvm_rbx_opt}}";
            fi
        ;;
        jruby)
            rvm_ruby_patch_level="";
            rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "jruby_repo_url")}";
            rvm_ruby_url="${rvm_ruby_repo_url:-$(__rvm_db "jruby_repo_url")}";
            if (( ${rvm_head_flag:=0} == 1 )); then
                rvm_disable_binary_flag=1;
                rvm_ruby_version="head";
            else
                if (( ${rvm_18_flag:-0} || ${rvm_19_flag:-0} || ${rvm_20_flag:-0} || ${#rvm_patch_names[@]} )); then
                    rvm_disable_binary_flag=1;
                fi;
                rvm_ruby_version="${rvm_ruby_version:-"$(__rvm_db "jruby_version")"}";
                rvm_ruby_tag="${rvm_ruby_tag:-${rvm_ruby_version}}";
            fi;
            alias jruby_ng="jruby --ng";
            alias jruby_ng_server="jruby --ng-server"
        ;;
        maglev)
            rvm_ruby_patch_level="";
            maglev_url="$(__rvm_db "maglev_url")";
            system="$(uname -s)";
            if [[ "$MACHTYPE" == x86_64-apple-darwin* ]]; then
                arch="i386";
            else
                arch="$(uname -m)";
            fi;
            if (( ${rvm_head_flag:=0} == 1 )) || [[ "$rvm_ruby_version" == "head" ]]; then
                rvm_head_flag=1;
                rvm_ruby_version="head";
                rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "maglev_repo_url")}";
                rvm_ruby_url="${rvm_ruby_repo_url:-$(__rvm_db "maglev_repo_url")}";
                rvm_gemstone_version=$(
          __rvm_curl -s https://raw.github.com/MagLev/maglev/master/version.txt |
            GREP_OPTIONS="" \grep "^GEMSTONE" | cut -f2 -d-
        );
                rvm_gemstone_package_file="GemStone-${rvm_gemstone_version}.${system}-${arch}";
                rvm_disable_binary_flag=1;
            else
                rvm_ruby_package_file="MagLev-${rvm_ruby_version}";
                rvm_ruby_version="${rvm_ruby_version:-"$(__rvm_db "maglev_version")"}";
                rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}";
                rvm_ruby_url="${rvm_ruby_url:-"$maglev_url/${rvm_ruby_package_file}.${rvm_archive_extension}"}";
                rvm_gemstone_version=$(
          __rvm_curl -s https://raw.github.com/MagLev/maglev/MagLev-${rvm_ruby_version}/version.txt |
            GREP_OPTIONS="" \grep "^GEMSTONE" | cut -f2 -d-
        );
                rvm_gemstone_package_file="GemStone-${rvm_gemstone_version}.${system}-${arch}";
                export MAGLEV_HOME="$rvm_rubies_path/$rvm_ruby_string";
            fi;
            rvm_gemstone_url="$maglev_url/${rvm_gemstone_package_file}.${rvm_archive_extension}"
        ;;
        ironruby)
            rvm_ruby_patch_level="";
            if (( ${rvm_head_flag:=0} == 1 )); then
                rvm_ruby_version="head";
                rvm_ruby_package_name="${rvm_ruby_string}";
                rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "ironruby_repo_url")}";
                rvm_ruby_url="${rvm_ruby_repo_url:-$(__rvm_db "ironruby_repo_url")}";
                rvm_disable_binary_flag=1;
            else
                rvm_archive_extension="zip";
                rvm_ruby_version=${rvm_ruby_version:-"$(__rvm_db "ironruby_version")"};
                rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}";
                rvm_ruby_package_file="${rvm_ruby_interpreter}-${rvm_ruby_version}.${rvm_archive_extension}";
                rvm_ruby_url="$(__rvm_db "ironruby_${rvm_ruby_version}_url")";
            fi;
            export rvm_ruby_version rvm_ruby_string rvm_ruby_package_name rvm_ruby_repo_url rvm_ruby_url rvm_archive_extension
        ;;
        ree)
            rvm_ruby_interpreter=ree;
            rvm_ruby_version=${rvm_ruby_version:-"$(__rvm_db "ree_version")"};
            case "$rvm_ruby_version" in
                1.8.*)
                    true
                ;;
                *)
                    rvm_error "Unknown Ruby Enterprise Edition version: $rvm_ruby_version"
                ;;
            esac;
            if [[ -n "${rvm_ruby_patch_level:-0}" ]]; then
                rvm_ruby_patch_level="$(echo $rvm_ruby_patch_level | \sed 's#^p##')";
            fi;
            rvm_ruby_package_file="ruby-enterprise-$rvm_ruby_version-$rvm_ruby_patch_level";
            rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_${rvm_ruby_patch_level}_url")";
            rvm_ruby_url="${rvm_ruby_url:-$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_url")}";
            rvm_ruby_url="${rvm_ruby_url}/$rvm_ruby_package_file.tar.gz"
        ;;
        kiji)
            rvm_ruby_interpreter="kiji";
            rvm_ruby_version="head";
            rvm_head_flag=1;
            rvm_ruby_string="kiji-head";
            rvm_ruby_patch_level="";
            rvm_ruby_repo_url=${rvm_ruby_repo_url:-"$(__rvm_db "kiji_repo_url")"};
            rvm_ruby_url=$rvm_ruby_repo_url;
            rvm_ruby_configure="";
            rvm_ruby_make="";
            rvm_ruby_make_install=""
        ;;
        goruby)
            rvm_ruby_interpreter="goruby";
            rvm_ruby_version="head";
            rvm_ruby_string="goruby";
            rvm_ruby_patch_level="";
            rvm_ruby_repo_url=${rvm_ruby_repo_url:-"$(__rvm_db "goruby_repo_url")"};
            rvm_ruby_url=$rvm_ruby_repo_url;
            rvm_ruby_configure="";
            rvm_ruby_make="";
            rvm_ruby_make_install=""
        ;;
        mruby)
            rvm_ruby_interpreter="mruby";
            rvm_ruby_version="head";
            rvm_ruby_string="mruby-head";
            rvm_ruby_patch_level="";
            rvm_ruby_repo_url=${rvm_ruby_repo_url:-"$(__rvm_db "mruby_repo_url")"};
            rvm_ruby_url=$rvm_ruby_repo_url;
            export rvm_head_flag=1;
            rvm_disable_binary_flag=1;
            export rvm_skip_autoreconf_flag=1;
            rvm_ruby_configure="";
            rvm_ruby_make="";
            rvm_ruby_make_install=""
        ;;
        tcs)
            rvm_ruby_interpreter="tcs";
            rvm_ruby_version="head";
            rvm_ruby_string="tcs";
            rvm_ruby_patch_level="";
            rvm_ruby_repo_url=${rvm_tcs_repo_url:-"$(__rvm_db "tcs_repo_url")"};
            rvm_ruby_url=$rvm_ruby_repo_url;
            rvm_ruby_repo_branch="${rvm_ruby_repo_branch:-"$(__rvm_db "tcs_repo_branch")"}";
            export rvm_head_flag=1;
            rvm_disable_binary_flag=1;
            rvm_ruby_configure="";
            rvm_ruby_make="";
            rvm_ruby_make_install=""
        ;;
        jamesgolick)
            rvm_ruby_interpreter="jamesgolick";
            rvm_ruby_version="head";
            rvm_ruby_string="jamesgolick";
            rvm_ruby_patch_level="";
            rvm_ruby_repo_url=${rvm_jamesgolick_repo_url:-"$(__rvm_db "jamesgolick_repo_url")"};
            rvm_ruby_url=$rvm_ruby_repo_url;
            rvm_ruby_repo_branch="${rvm_ruby_repo_branch:-"$(__rvm_db "jamesgolick_repo_branch")"}";
            export rvm_head_flag=1;
            rvm_disable_binary_flag=1;
            rvm_ruby_configure="";
            rvm_ruby_make="";
            rvm_ruby_make_install=""
        ;;
        ruby)
            if [[ -n "${rvm_ruby_patch_level}" ]]; then
                rvm_ruby_package_file="${rvm_ruby_interpreter}-${rvm_ruby_version}-${rvm_ruby_patch_level}";
                rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}-${rvm_ruby_patch_level}";
            else
                rvm_ruby_package_file="${rvm_ruby_interpreter}-${rvm_ruby_version}";
                rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}";
            fi;
            if [[ -z "${rvm_ruby_version:-""}" ]] && (( ${rvm_head_flag:=0} == 0 )); then
                rvm_error "Ruby version was not specified!";
            else
                rvm_ruby_repo_url="${rvm_ruby_repo_url:-"$(__rvm_db "ruby_repo_url")"}";
                if (( ${rvm_head_flag:=0} == 0 )); then
                    if __rvm_version_compare "${rvm_ruby_version}" -lt "1.8.5"; then
                        rvm_archive_extension="tar.gz";
                    else
                        rvm_archive_extension="tar.bz2";
                    fi;
                else
                    rvm_disable_binary_flag=1;
                fi;
            fi
        ;;
        ext)
            if [[ -z "${rvm_ruby_name:-${detected_rvm_ruby_name:-}}" ]]; then
                rvm_error "External ruby name was not specified!";
            fi
        ;;
        current)
            ruby_binary="$(builtin command -v ruby)";
            if (( $? == 0)) && __rvm_string_match "$ruby_binary" "*rvm*"; then
                rvm_ruby_string="$(dirname "$ruby_binary" | xargs dirname | xargs basename)";
            else
                rvm_ruby_interpreter="system";
            fi
        ;;
        default | system | user)
            true
        ;;
        *)
            if [[ -n "${MY_RUBY_HOME:-""}" ]]; then
                __rvm_select $(basename $MY_RUBY_HOME);
            else
                if [[ -z "${rvm_ruby_string:-""}" ]]; then
                    rvm_error "Ruby implementation '$rvm_ruby_interpreter' is not known.";
                    return 1;
                fi;
            fi
        ;;
    esac;
    if [[ -n "$rvm_ruby_version" ]]; then
        case "$rvm_ruby_version" in
            +([[:digit:]]).+([[:digit:]]).+([[:digit:]]))
                rvm_ruby_release_version="${rvm_ruby_version/.*/}";
                rvm_ruby_major_version=${rvm_ruby_version%.*};
                rvm_ruby_major_version=${rvm_ruby_major_version#*.};
                rvm_ruby_minor_version="${rvm_ruby_version//*.}"
            ;;
            +([[:digit:]]).+([[:digit:]]))
                rvm_ruby_release_version="${rvm_ruby_version/.*/}";
                rvm_ruby_major_version="${rvm_ruby_version#*.}";
                rvm_ruby_minor_version=""
            ;;
        esac;
    fi;
    if [[ "${rvm_ruby_interpreter}" == ext ]]; then
        rvm_ruby_home="${rvm_externals_path:-$rvm_path/externals}/$rvm_ruby_string";
        rvm_ruby_binary="$rvm_rubies_path/$rvm_ruby_string/bin/ruby";
    else
        rvm_ruby_home="$rvm_rubies_path/$rvm_ruby_string";
        rvm_ruby_binary="$rvm_ruby_home/bin/ruby";
        rvm_ruby_package_name="${rvm_ruby_package_name:-${rvm_ruby_string//-n*}}";
    fi;
    rvm_ruby_irbrc="$rvm_ruby_home/.irbrc";
    if [[ "maglev" == "$rvm_ruby_interpreter" ]]; then
        export MAGLEV_HOME="$rvm_ruby_home";
        export GEMSTONE_GLOBAL_DIR=$MAGLEV_HOME;
    fi;
    [[ "system" == "$rvm_ruby_interpreter" ]] || {
        __rvm_gemset_select || case $? in
            2)
                true
            ;;
            *)
                return $?
            ;;
        esac
    };
    rvm_ruby_selected_flag=1;
    [[ -d "${rvm_log_path}/$rvm_ruby_string" ]] || \mkdir -p "${rvm_log_path}/$rvm_ruby_string"
}
__rvm_select_macruby_nightly ()
{
    __rvm_db "macruby_nightly_url" "rvm_ruby_url";
    case "${rvm_ruby_version:-}" in
        nightly_*)
            __rvm_select_macruby_nightly_selected
        ;;
        *)
            __rvm_select_macruby_nightly_detect
        ;;
    esac;
    rvm_ruby_url+="/${rvm_ruby_package_file}";
    rvm_verify_downloads_flag=1;
    rvm_debug "selected macruby $rvm_ruby_string => $rvm_ruby_url"
}
__rvm_select_macruby_nightly_detect ()
{
    typeset __string_version;
    rvm_ruby_version="$(
    __rvm_curl -s "$rvm_ruby_url" |
    GREP_OPTIONS="" \grep -oE "<a href=\"macruby_nightly-[^<]+\.pkg</a>" |
    awk -F"[<>]" '{print $3}' | sort | tail -n 1
  )";
    [[ -n "${rvm_ruby_version}" ]] || {
        rvm_error "Could not find MacRuby nightly binary.";
        return 1
    };
    rvm_ruby_package_file="${rvm_ruby_version}";
    rvm_ruby_package_name="${rvm_ruby_package_file%.pkg}";
    __string_version="${rvm_ruby_package_name#macruby_nightly-}";
    __string_version="${__string_version//-/.}";
    rvm_ruby_version="nightly_${__string_version}";
    rvm_ruby_string="macruby-${rvm_ruby_version}${rvm_ruby_name:+-}${rvm_ruby_name:-}"
}
__rvm_select_macruby_nightly_selected ()
{
    typeset __string_version;
    __string_version="${rvm_ruby_version//./-}";
    __string_version="${__string_version#nightly_}";
    rvm_ruby_package_name="${rvm_ruby_interpreter}_nightly-${__string_version}";
    rvm_ruby_package_file="$rvm_ruby_package_name.pkg"
}
__rvm_select_rbx_nightly ()
{
    (( ${rvm_nightly_flag:=0} == 1 )) || return 0;
    typeset org_rvm_ruby_patch_level _rvm_ruby_name;
    if [[ "$rvm_ruby_version" == head ]]; then
        rvm_ruby_version="";
    fi;
    rvm_debug "searching for binary rbx ${rvm_ruby_version:-}${rvm_ruby_version:+-}${rvm_ruby_patch_level}*${rvm_ruby_name:+-}${rvm_ruby_name:-}";
    org_rvm_ruby_patch_level="$rvm_ruby_patch_level";
    _rvm_ruby_name="${rvm_ruby_name:-${detected_rvm_ruby_name:-}}";
    rvm_ruby_patch_level="$(
    __list_remote_rbx_for $( __rvm_system_path_for rbx ) |
      GREP_OPTIONS="" \grep ${rvm_ruby_version:-}${rvm_ruby_version:+-}${org_rvm_ruby_patch_level}.*${_rvm_ruby_name:+-}${_rvm_ruby_name:-} |
      tail -n 1
  )";
    [[ -n "${rvm_ruby_patch_level:-}" ]] || {
        rvm_error "Could not find rbx binary '${rvm_ruby_version:-}${rvm_ruby_version:+-}${org_rvm_ruby_patch_level}*${rvm_ruby_name:+-}${rvm_ruby_name:-}' release for '$( __rvm_system_path_for rbx )'.";
        return 1
    };
    rvm_ruby_patch_level="${rvm_ruby_patch_level##*/}";
    rvm_ruby_patch_level="${rvm_ruby_patch_level%.tar.*}";
    if [[ -z "${rvm_ruby_version:-}" ]]; then
        rvm_ruby_patch_level="${rvm_ruby_patch_level#rubinius-}";
        rvm_ruby_version="${rvm_ruby_patch_level%%-*}";
    fi;
    if [[ -z "${rvm_ruby_name:-}" ]]; then
        rvm_ruby_name="${rvm_ruby_patch_level##*-}";
    fi;
    rvm_ruby_patch_level="${rvm_ruby_patch_level##*${org_rvm_ruby_patch_level}}";
    rvm_ruby_patch_level="${rvm_ruby_patch_level%%-*}";
    rvm_ruby_patch_level="${org_rvm_ruby_patch_level}${rvm_ruby_patch_level}";
    rvm_ruby_string="rubinius-${rvm_ruby_version}-${rvm_ruby_patch_level}-${rvm_ruby_name}";
    rvm_debug "detected rbx ${rvm_ruby_string}";
    rvm_verify_downloads_flag=1
}
__rvm_set_color ()
{
    typeset __buffer __variable;
    __buffer='[';
    __variable="$1";
    shift;
    while (( $# )); do
        __rvm_set_color_single "$1";
        shift;
        if (( $# )); then
            __buffer+=';';
        fi;
    done;
    __buffer+='m';
    if [[ "${__variable}" == "" || "${__variable}" == "print" ]]; then
        printf "${__buffer}";
    else
        eval "${__variable}='${__buffer}'";
    fi
}
__rvm_set_color_single ()
{
    case "$1" in
        bold)
            __buffer+='7'
        ;;
        offbold)
            __buffer+='27'
        ;;
        black)
            __buffer+='30'
        ;;
        red)
            __buffer+='31'
        ;;
        green)
            __buffer+='32'
        ;;
        yellow)
            __buffer+='33'
        ;;
        blue)
            __buffer+='34'
        ;;
        magenta)
            __buffer+='35'
        ;;
        cyan)
            __buffer+='36'
        ;;
        white)
            __buffer+='37'
        ;;
        default)
            __buffer+='39'
        ;;
        bblack)
            __buffer+='40'
        ;;
        bred)
            __buffer+='41'
        ;;
        bgreen)
            __buffer+='42'
        ;;
        byellow)
            __buffer+='43'
        ;;
        bblue)
            __buffer+='44'
        ;;
        bmagenta)
            __buffer+='45'
        ;;
        bcyan)
            __buffer+='46'
        ;;
        bwhite)
            __buffer+='47'
        ;;
        bdefault)
            __buffer+='49'
        ;;
        *)
            __buffer+='0'
        ;;
    esac
}
__rvm_set_ruby_version ()
{
    if [[ -s .ruby-version ]]; then
        \mv .ruby-version .ruby-version.$(date +%m.%d.%Y-%H:%M:%S);
        rvm_warn ".ruby-version is not empty, moving aside to preserve.";
    fi;
    typeset __version="$(__rvm_env_string)";
    case "${__version}" in
        *@*)
            if [[ -s .ruby-gemset ]]; then
                \mv .ruby-gemset .ruby-gemset.$(date +%m.%d.%Y-%H:%M:%S);
                rvm_warn ".ruby-gemset is not empty, moving aside to preserve.";
            fi;
            echo "${__version##*@}" > .ruby-gemset
        ;;
        *)
            if [[ -s .ruby-gemset ]]; then
                \mv .ruby-gemset .ruby-gemset.$(date +%m.%d.%Y-%H:%M:%S);
                rvm_warn ".ruby-gemset not needed, moving aside to preserve.";
            fi
        ;;
    esac;
    echo "${__version%@*}" > .ruby-version
}
__rvm_set_rvmrc ()
{
    typeset flags identifier short_identifier gem_file;
    true ${rvm_verbose_flag:=0};
    if [[ "$HOME" != "$PWD" && "${rvm_prefix:-}" != "$PWD" ]]; then
        if (( rvm_verbose_flag )); then
            flags="use ";
        fi;
        if [[ -s .rvmrc ]]; then
            \mv .rvmrc .rvmrc.$(date +%m.%d.%Y-%H:%M:%S);
            rvm_warn ".rvmrc is not empty, moving aside to preserve.";
        fi;
        identifier=$(__rvm_env_string);
        short_identifier="${identifier#ruby-}";
        short_identifier="${short_identifier%%-*}";
        printf "%b" "#!/usr/bin/env bash

# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory

# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
# Only full ruby name is supported here, for short names use:
#     echo \"rvm use ${short_identifier}\" > .rvmrc
environment_id=\"$identifier\"

# Uncomment the following lines if you want to verify rvm version per project
# rvmrc_rvm_version=\"${rvm_version}\" # 1.10.1 seems like a safe start
# eval \"\$(echo \${rvm_version}.\${rvmrc_rvm_version} | awk -F. '{print \"[[ \"\$1*65536+\$2*256+\$3\" -ge \"\$4*65536+\$5*256+\$6\" ]]\"}' )\" || {
#   echo \"This .rvmrc file requires at least RVM \${rvmrc_rvm_version}, aborting loading.\"
#   return 1
# }
" >> .rvmrc;
        if __rvm_string_match "$identifier" "jruby*"; then
            printf "%b" "
# Uncomment following line if you want options to be set only for given project.
# PROJECT_JRUBY_OPTS=( --1.9 )
# The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
#    chmod +x \${rvm_path}/hooks/after_use_jruby_opts
" >> .rvmrc;
        fi;
        printf "%b" "
# First we attempt to load the desired environment directly from the environment
# file. This is very fast and efficient compared to running through the entire
# CLI and selector. If you want feedback on which environment was used then
# insert the word 'use' after --create as this triggers verbose mode.
if [[ -d \"\${rvm_path:-\$HOME/.rvm}/environments\"
  && -s \"\${rvm_path:-\$HOME/.rvm}/environments/\$environment_id\" ]]
then
  \\. \"\${rvm_path:-\$HOME/.rvm}/environments/\$environment_id\"
  for __hook in \"\${rvm_path:-\$HOME/.rvm}/hooks/after_use\"*
  do
    if [[ -f \"\${__hook}\" && -x \"\${__hook}\" && -s \"\${__hook}\" ]]
    then \\. \"\${__hook}\" || true
    fi
  done
  unset __hook
" >> .rvmrc;
        if [[ " $flags " =~ " use " ]]; then
            printf "%b" "  if (( \${rvm_use_flag:=1} >= 1 )) # display automatically" >> .rvmrc;
        else
            printf "%b" "  if (( \${rvm_use_flag:=1} >= 2 )) # display only when forced" >> .rvmrc;
        fi;
        printf "%b" "
  then
    if [[ \$- == *i* ]] # check for interactive shells
    then printf \"%b\" \"Using: \\\\E[32m\$GEM_HOME\\\\E[0m\\n\" # show the user the ruby and gemset they are using in green
    else printf \"%b\" \"Using: \$GEM_HOME\\n\" # don't use colors in non-interactive shells
    fi
  fi
" >> .rvmrc;
        printf "%b" "else
  # If the environment file has not yet been created, use the RVM CLI to select.
  rvm --create $flags \"\$environment_id\" || {
    echo \"Failed to create RVM environment '\${environment_id}'.\"
    return 1
  }
fi
" >> .rvmrc;
        for gem_file in *.gems;
        do
            case "$gem_file" in
                \*.gems)
                    continue
                ;;
            esac;
            printf "%b" "
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
# it be automatically loaded. Uncomment the following and adjust the filename if
# necessary.
#
# filename=\".gems\"
# if [[ -s \"\$filename\" ]]
# then
#   rvm gemset import \"\$filename\" | GREP_OPTIONS="" \grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
# fi
" >> .rvmrc;
        done;
        if [[ -s Gemfile ]]; then
            printf "%b" "
# If you use bundler, this might be useful to you:
# if [[ -s Gemfile ]] && {
#   ! builtin command -v bundle >/dev/null ||
#   builtin command -v bundle | GREP_OPTIONS="" \grep \$rvm_path/bin/bundle >/dev/null
# }
# then
#   printf \"%b\" \"The rubygem 'bundler' is not installed. Installing it now.\\\\n\"
#   gem install bundler
# fi
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
# then
#   bundle install | GREP_OPTIONS="" \grep -vE '^Using|Your bundle is complete'
# fi
" >> .rvmrc;
        fi;
    else
        rvm_error ".rvmrc cannot be set in your home directory.      \nThe home .rvmrc is for global rvm settings only.";
    fi
}
__rvm_set_versions_conf ()
{
    typeset gemset identifier;
    if [[ -s .versions.conf ]]; then
        \mv .versions.conf .versions.conf.$(date +%m.%d.%Y-%H:%M:%S);
        rvm_warn ".version.conf is not empty, moving aside to preserve.";
    fi;
    identifier=$(__rvm_env_string);
    gemset=${identifier#*@};
    identifier=${identifier%@*};
    printf "%b" "ruby=$identifier
" >> .versions.conf;
    if [[ -n "$gemset" && "$gemset" != "$identifier" ]]; then
        printf "%b" "ruby-gemset=$gemset
" >> .versions.conf;
    else
        printf "%b" "#ruby-gemset=my-projectit
" >> .versions.conf;
    fi;
    printf "%b" "#ruby-gem-install=bundler rake
#ruby-bundle-install=true
" >> .versions.conf
}
__rvm_setup ()
{
    __variables_definition export;
    if (( __rvm_env_loaded != 1 )); then
        return 0;
    fi;
    if [[ -n "${BASH_VERSION:-}" ]] && ! __function_on_stack cd pushd popd; then
        trap 'status=$? ; __rvm_teardown_final ; set +x ; return $status' 0 1 2 3 15;
    fi;
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        export rvm_zsh_clobber rvm_zsh_nomatch;
        if setopt | GREP_OPTIONS="" \grep -s '^noclobber$' > /dev/null 2>&1; then
            rvm_zsh_clobber=0;
        else
            rvm_zsh_clobber=1;
        fi;
        setopt clobber;
        if setopt | GREP_OPTIONS="" \grep -s '^nonomatch$' > /dev/null 2>&1; then
            rvm_zsh_nomatch=0;
        else
            rvm_zsh_nomatch=1;
        fi;
        setopt no_nomatch;
    fi
}
__rvm_setup_cd ()
{
    typeset __cd_prefix __command;
    __cd_prefix="";
    if typeset -f smartcd > /dev/null 2> /dev/null; then
        __cd_prefix="smartcd";
    fi;
    if typeset -f exec_scmb_expand_args > /dev/null 2> /dev/null; then
        __cd_prefix="exec_scmb_expand_args ${__cd_prefix:-builtin}";
    fi;
    [[ -n "${__cd_prefix}" ]] || __cd_prefix="builtin";
    function __rvm_after_cd ()
    {
        typeset rvm_hook;
        rvm_hook="after_cd";
        if [[ -n "${rvm_scripts_path:-}" || -n "${rvm_path:-}" ]]; then
            source "${rvm_scripts_path:-$rvm_path/scripts}/hook";
        fi
    };
    function __rvm_cd_functions_set ()
    {
        __rvm_do_with_env_before;
        __rvm_project_rvmrc && __rvm_after_cd || true;
        __rvm_do_with_env_after;
        return 0
    };
    function __rvm_setup_cd_function ()
    {
        typeset __cd_prefix __command;
        __cd_prefix=$1;
        __command=$2;
        eval "
${__command}(){
  if ${__cd_prefix} ${__command} \"\$@\"
  then
    [[ -n \"\${rvm_current_rvmrc:-""}\" && \"\$*\" == \".\" ]] && rvm_current_rvmrc=\"\" || true
    __rvm_cd_functions_set
    return 0
  else
    return \$?
  fi
}"
    };
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        autoload is-at-least;
        if is-at-least 4.3.4 > /dev/null 2>&1; then
            export -a chpwd_functions;
            chpwd_functions=("${chpwd_functions[@]}" __rvm_cd_functions_set);
        else
            for __command in cd popd pushd;
            do
                __rvm_setup_cd_function "${__cd_prefix}" "${__command}";
            done;
        fi;
    else
        for __command in cd popd pushd;
        do
            __rvm_setup_cd_function "${__cd_prefix}" "${__command}";
        done;
    fi
}
__rvm_setup_cd_function ()
{
    typeset __cd_prefix __command;
    __cd_prefix=$1;
    __command=$2;
    eval "
${__command}(){
  if ${__cd_prefix} ${__command} \"\$@\"
  then
    [[ -n \"\${rvm_current_rvmrc:-""}\" && \"\$*\" == \".\" ]] && rvm_current_rvmrc=\"\" || true
    __rvm_cd_functions_set
    return 0
  else
    return \$?
  fi
}"
}
__rvm_sha256_for_contents ()
{
    if builtin command -v sha256sum > /dev/null; then
        sha256sum | awk '{print $1}';
    else
        if builtin command -v sha256 > /dev/null; then
            sha256 | awk '{print $1}';
        else
            if builtin command -v shasum > /dev/null; then
                shasum -a256 | awk '{print $1}';
            else
                if builtin command -v openssl > /dev/null; then
                    openssl sha -sha256 | awk '{print $1}';
                else
                    return 1;
                fi;
            fi;
        fi;
    fi;
    true
}
__rvm_sha__calculate ()
{
    typeset bits _sum;
    bits=${1:-512};
    shift;
    if builtin command -v sha${bits}sum > /dev/null; then
        _sum=$(sha${bits}sum    "$@");
        echo ${_sum% *};
        return 0;
    else
        if builtin command -v sha${bits} > /dev/null; then
            _sum=$(sha${bits}       "$@");
            echo ${_sum% *};
            return 0;
        else
            if builtin command -v shasum > /dev/null; then
                _sum=$(shasum -a${bits} "$@");
                echo ${_sum% *};
                return 0;
            fi;
        fi;
    fi;
    rvm_error "Neither sha512sum nor shasum found in the PATH";
    return 1
}
__rvm_source_dir ()
{
    if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]]; then
        __rvm_select;
    fi;
    if [[ -z "$rvm_ruby_src_path" ]]; then
        rvm_error "No source directory exists for the default implementation.";
    else
        echo "$rvm_ruby_src_path";
    fi;
    return 0
}
__rvm_string_includes ()
{
    typeset __search __text="$1";
    shift;
    for __search in "$@";
    do
        if [[ " ${__text} " =~ " ${__search} " ]]; then
            return 0;
        fi;
    done;
    return 1
}
__rvm_string_match ()
{
    typeset _string;
    _string="$1";
    shift;
    while (( $# )); do
        case "${_string}" in
            $1)
                return 0
            ;;
        esac;
        shift;
    done;
    return 1
}
__rvm_strings ()
{
    typeset strings ruby_strings;
    ruby_strings=($(echo ${rvm_ruby_args:-$rvm_ruby_string}));
    for rvm_ruby_string in "${ruby_strings[@]}";
    do
        strings="$strings $(__rvm_select ; echo $rvm_ruby_string)";
    done;
    echo $strings;
    return 0
}
__rvm_strip ()
{
    \sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]\{1,\}/ /g';
    return $?
}
__rvm_switch ()
{
    typeset new_rvm_path new_rvm_bin_path;
    (( $# )) && [[ -z "$1" ]] && shift || true;
    (( $# )) && [[ -n "$1" ]] && [[ -d "$1" || -d "${1%/*}" ]] && [[ ! -f "$1" ]] || {
        rvm_error "No valid path given.";
        return 1
    };
    [[ "${rvm_path}" != "${new_rvm_path}" ]] || {
        rvm_warn "Already there!";
        return 2
    };
    rvm_log "Switching ${rvm_path} => ${1}";
    new_rvm_path="${1%/}";
    new_rvm_bin_path="${2:-$new_rvm_path/bin}";
    new_rvm_bin_path="${new_rvm_bin_path%/}";
    __rvm_use_system;
    __rvm_remove_from_path "${rvm_path%/}/*";
    rvm_reload_flag=1;
    rvm_path="${new_rvm_path}";
    rvm_bin_path="${new_rvm_bin_path}";
    rvm_scripts_path="${rvm_path}/scripts";
    rvm_environments_path="${rvm_path}/environments";
    __rvm_remove_from_path "${rvm_path%/}/*";
    __rvm_add_to_path prepend "${rvm_bin_path}"
}
__rvm_system_path ()
{
    rvm_remote_server_path="$(__rvm_db "rvm_remote_server_path${2:-}")";
    [[ -n "${rvm_remote_server_path}" ]] || if __rvm_detect_system; then
        rvm_remote_server_path="${_system_name}/${_system_version}/${_system_arch}";
    else
        return $?;
    fi;
    if [[ "${1:-}" == "-" ]]; then
        printf "%b" "${rvm_remote_server_path}\n";
    fi
}
__rvm_system_path_for ()
{
    typeset _iterator rvm_remote_server_type rvm_remote_server_path;
    _iterator="";
    while :; do
        rvm_remote_server_type="$(__rvm_db "rvm_remote_server_type${_iterator}")";
        [[ -n "${rvm_remote_server_type}" ]] || return 0;
        if [[ "${rvm_remote_server_type}" == "$1" || "$1" == "all" ]]; then
            __rvm_system_path - "${_iterator}";
        fi;
        : $(( _iterator+=1 ));
    done | sort -u | \tr "\n" "|" | sed 's/|$//'
}
__rvm_table ()
{
    if [[ -n "${1:-}" ]]; then
        __rvm_table_br;
        echo "$1" | __rvm_table_wrap_text;
    fi;
    __rvm_table_br;
    \cat "${2:--}" | __rvm_table_wrap_text;
    __rvm_table_br
}
__rvm_table_br ()
{
    typeset width=${COLUMNS:-78};
    width=$(( width > 116 ? 116 : width ));
    printf "%-${width}s\n" " " | sed 's/ /*/g'
}
__rvm_table_wrap_text ()
{
    typeset width=${COLUMNS:-78};
    width=$(( width > 116 ? 116 : width ));
    width=$(( width - 4 ));
    __rvm_fold $width | awk -v width=$width '{printf "* %-"width"s *\n", $0}'
}
__rvm_teardown ()
{
    if builtin command -v __rvm_cleanup_tmp > /dev/null 2>&1; then
        __rvm_cleanup_tmp;
    fi;
    export __rvm_env_loaded;
    : __rvm_env_loaded:${__rvm_env_loaded:=${rvm_tmp_path:+1}}:;
    : __rvm_env_loaded:${__rvm_env_loaded:=0}:;
    : __rvm_env_loaded:$(( __rvm_env_loaded-=1 )):;
    if [[ -z "${rvm_tmp_path:-}" ]] || (( __rvm_env_loaded > 0 )); then
        return 0;
    fi;
    if [[ -n "${BASH_VERSION:-}" ]]; then
        trap - 0 1 2 3 15;
    fi;
    if [[ -n "${ZSH_VERSION:-""}" ]]; then
        (( rvm_zsh_clobber == 0 )) && setopt noclobber;
        (( rvm_zsh_nomatch == 0 )) || setopt nomatch;
        unset rvm_zsh_clobber rvm_zsh_nomatch;
    fi;
    if [[ -n "${rvm_stored_umask:-}" ]]; then
        umask ${rvm_stored_umask};
        unset rvm_stored_umask;
    fi;
    if [[ "${rvm_stored_errexit:-""}" == "1" ]]; then
        set -e;
    fi;
    __variables_definition unset;
    if builtin command -v __rvm_cleanup_download > /dev/null 2>&1; then
        __rvm_cleanup_download;
    fi;
    return 0
}
__rvm_teardown_final ()
{
    __rvm_env_loaded=1;
    unset __rvm_project_rvmrc_lock;
    __rvm_teardown
}
__rvm_trust_rvmrc ()
{
    [[ -f "$1" ]] || return 1;
    __rvm_reset_rvmrc_trust "$1";
    "$rvm_scripts_path/db" "$rvm_user_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "1;$(__rvm_checksum_for_contents "$1")" > /dev/null 2>&1 || return $?
}
__rvm_try_sudo ()
{
    ( typeset -a command_to_run;
    command_to_run=("$@");
    (( UID == 0 )) || case "$rvm_autolibs_flag_number" in
        0)
            rvm_debug "Running '$*' would require sudo.";
            return 0
        ;;
        1)
            rvm_warn "Running '$*' would require sudo.";
            return 0
        ;;
        2)
            rvm_requiremnts_fail error "Running '$*' would require sudo.";
            return 1
        ;;
        *)
            if __rvm_which sudo > /dev/null; then
                command_to_run=(sudo "${command_to_run[@]}");
            else
                rvm_requiremnts_fail error "Running '$*' would require sudo, but 'sudo' is not available!";
                return 1;
            fi
        ;;
    esac;
    "${command_to_run[@]}" || return $? )
}
__rvm_unload ()
{
    typeset _element;
    typeset -a _list;
    __rvm_remove_rvm_from_path;
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        __rvm_remove_from_array fpath "$rvm_path/scripts/extras/completion.zsh" "${fpath[@]}";
    fi;
    __rvm_unload_action unalias <(
    if [[ -n "${ZSH_VERSION:-}" ]]
    then alias | awk -F"=" '/rvm/ {print $1}'
    else alias | awk -F"[= ]" '/rvm/ {print $2}'
    fi
  );
    __rvm_unload_action unset <(
    set |
      awk -F"=" 'BEGIN{v=0;} /^[a-zA-Z_][a-zA-Z0-9_]*=/{v=1;} v==1&&$2~/^['\''\$]/{v=2;}
        v==1&&$2~/^\(/{v=3;} v==2&&/'\''$/&&!/'\'\''$/{v=1;} v==3&&/\)$/{v=1;} v{print;} v==1{v=0;}' |
      awk -F"=" '/^[^ ]*(RUBY|GEM|IRB|gem|rubies|rvm)[^ ]*=/ {print $1} /^[^ ]*=.*rvm/ {print $1}' |
      \grep -vE "^PROMPT|^prompt|^PS|^BASH_SOURCE"
  );
    __rvm_unload_action __function_unset <(
    typeset -f | awk '$2=="()" {fun=$1} /rvm/{print fun}' | sort -u | \grep -v __rvm_unload_action
  );
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        unset -f __rvm_unload_action;
        unset -f __function_unset;
        if [[ -n "${_comp_dumpfile:-}" ]]; then
            \rm -f "$_comp_dumpfile";
            compinit -d "$_comp_dumpfile";
        fi;
    else
        unset __rvm_unload_action __function_unset;
    fi
}
__rvm_unload_action ()
{
    typeset _element IFS;
    typeset -a _list;
    IFS='
';
    _list=($( \cat ${2:--} | sort -u ));
    for _element in "${_list[@]}";
    do
        $1 "${_element}";
    done
}
__rvm_unset_exports ()
{
    typeset wrap_name name value;
    while IFS== read -d "" wrap_name value; do
        case "$wrap_name" in
            rvm_old_*)
                name=${wrap_name#rvm_old_};
                if [[ -n "${value:-}" ]]; then
                    export $name="${value}";
                else
                    unset $name;
                fi;
                unset $wrap_name
            ;;
        esac;
    done < <(printenv_null)
}
__rvm_unset_ruby_variables ()
{
    unset rvm_env_string rvm_ruby_string rvm_ruby_strings rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_log_path rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_repo_branch rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_tag rvm_ruby_version rvm_head_flag rvm_ruby_package_file rvm_ruby_configure rvm_ruby_name rvm_ruby_url rvm_ruby_global_gems_path rvm_ruby_args rvm_ruby_name rvm_llvm_flag;
    __rvm_load_rvmrc
}
__rvm_untrust_rvmrc ()
{
    [[ -f "$1" ]] || return 1;
    __rvm_reset_rvmrc_trust "$1";
    "${rvm_scripts_path:-"$rvm_path/scripts"}/db" "$rvm_user_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "0;$(__rvm_checksum_for_contents "$1")" > /dev/null 2>&1 || return $?
}
__rvm_use ()
{
    typeset new_path binary full_binary_path rvm_ruby_gem_home;
    __rvm_select "$@" || return $?;
    if [[ "system" == ${rvm_ruby_interpreter:="system"} ]]; then
        __rvm_use_system;
    else
        if [[ ! -d "$rvm_ruby_home" ]]; then
            if [[ ${rvm_install_on_use_flag:-0} -eq 1 ]]; then
                rvm_warn "$rvm_ruby_string is not installed.";
                __rvm_run_wrapper manage "install" "$rvm_ruby_string";
            else
                rvm_error "$rvm_ruby_string is not installed.";
                rvm_log "To install do: 'rvm install $rvm_ruby_string'";
                export rvm_recommended_ruby="rvm install $rvm_ruby_string";
                return 1;
            fi;
        fi;
        if [[ ! -d "$rvm_ruby_gem_home" || -n "${rvm_expected_gemset_name}" ]]; then
            if (( ${rvm_gemset_create_on_use_flag:=0} == 1 || ${rvm_create_flag:=0} == 1 )); then
                rvm_warn "gemset $rvm_gemset_name is not existing, creating.";
                "$rvm_scripts_path/gemsets" create "$rvm_gemset_name";
            else
                rvm_error "Gemset '${rvm_expected_gemset_name}' does not exist, 'rvm $rvm_ruby_string do rvm gemset create ${rvm_expected_gemset_name}' first, or append '--create'.";
                return 2;
            fi;
        fi;
        export GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION IRBRC;
        GEM_HOME="$rvm_ruby_gem_home";
        GEM_PATH="$rvm_ruby_gem_path";
        MY_RUBY_HOME="$rvm_ruby_home";
        RUBY_VERSION="$rvm_ruby_string";
        IRBRC="$rvm_ruby_irbrc";
        unset BUNDLE_PATH;
        if [[ "maglev" == "$rvm_ruby_interpreter" ]]; then
            GEM_PATH="$GEM_PATH:$MAGLEV_HOME/lib/maglev/gems/1.8/";
        fi;
        [[ -n "${IRBRC:-}" ]] || unset IRBRC;
        __rvm_ensure_has_environment_files;
        if (( ${rvm_use_flag:-1} >= 2 )) || (( ${rvm_use_flag:-1} == 1 && ${rvm_verbose_flag:-0} == 1 )); then
            rvm_log "Using ${GEM_HOME/${rvm_gemset_separator:-'@'}/ with gemset }";
        fi;
        if [[ "$GEM_HOME" != "$rvm_ruby_global_gems_path" ]]; then
            new_path="$GEM_HOME/bin:$rvm_ruby_global_gems_path/bin:${rvm_ruby_binary%/*}:${rvm_bin_path}:$(__rvm_remove_rvm_from_path ;printf "%b" "$PATH")";
        else
            new_path="$GEM_HOME/bin:${rvm_ruby_binary%/*}:${rvm_bin_path}:$(__rvm_remove_rvm_from_path ;printf "%b" "$PATH")";
        fi;
    fi;
    [[ -z "${rvm_ruby_string:-}" ]] || export rvm_ruby_string;
    [[ -z "${rvm_gemset_name:-}" ]] || export rvm_gemset_name;
    if [[ -n "$new_path" ]]; then
        export PATH="$new_path";
        unset new_path;
        builtin hash -r;
    fi;
    if [[ "$rvm_ruby_string" != "system" ]]; then
        case "${rvm_rvmrc_flag:-0}" in
            rvmrc | versions_conf | ruby_version)
                __rvm_set_${rvm_rvmrc_flag}
            ;;
        esac;
        typeset environment_id;
        environment_id="$(__rvm_env_string)";
        if (( ${rvm_default_flag:=0} == 1 )) && [[ "default" != "${rvm_ruby_interpreter:-}" ]] && [[ "system" != "${rvm_ruby_interpreter:-}" ]]; then
            "$rvm_scripts_path/alias" delete default >&/dev/null;
            "$rvm_scripts_path/alias" create default "$environment_id" >&/dev/null;
        fi;
        rvm_default_flag=0;
        if [[ -n "${rvm_wrapper_name:-}" ]]; then
            "$rvm_scripts_path/wrapper" "$environment_id" "$rvm_wrapper_name" > /dev/null 2>&1;
            rvm_wrapper_name="";
        fi;
        if [[ -n "${rvm_ruby_alias:-}" ]]; then
            rvm_log "Attempting to alias $environment_id to $rvm_ruby_alias";
            "$rvm_scripts_path/alias" delete "$rvm_ruby_alias" > /dev/null 2>&1;
            rvm_alias_expanded=1 "$rvm_scripts_path/alias" create "$rvm_ruby_alias" "$environment_id" > /dev/null 2>&1;
            ruby_alias="";
            rvm_ruby_alias="";
        fi;
    else
        if (( ${rvm_default_flag:=0} == 1 )); then
            if ! builtin command -v __rvm_reset >> /dev/null 2>&1; then
                source "$rvm_scripts_path/functions/reset";
                __rvm_reset;
            fi;
        fi;
    fi;
    rvm_hook="after_use";
    source "$rvm_scripts_path/hook";
    return 0
}
__rvm_use_ruby_warnings ()
{
    if [[ "${rvm_ruby_string}" == "system" ]]; then
        return 0;
    fi;
    typeset __executable __gem_version;
    for __executable in ruby gem irb;
    do
        [[ -x "$MY_RUBY_HOME/bin/${__executable}" ]] || rvm_warn "Warning! Executable '${__executable}' missing, something went wrong with this ruby installation!";
    done;
    if [[ "${rvm_ruby_interpreter}" == "ruby" ]] && {
        __rvm_version_compare "${rvm_ruby_version}" -ge 2.0.0 || [[ "${rvm_ruby_version}" == "head" ]]
    } && __rvm_which gem > /dev/null && __gem_version="$(gem --version)" && [[ -n "${__gem_version}" ]] && __rvm_version_compare "${__gem_version}" -lt "2.0.0"; then
        rvm_warn "Warning! You have just used ruby 2.0.0 or newer, which is not fully compatible with rubygems 1.8.x or older,
         consider upgrading rubygems with: 'rvm rubygems latest'.";
    fi
}
__rvm_use_system ()
{
    unset GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION IRBRC;
    new_path="$(__rvm_remove_rvm_from_path ; printf "%b" "$PATH"):${rvm_bin_path}";
    if [[ -s "$rvm_path/config/system" ]]; then
        if GREP_OPTIONS="" \grep "MY_RUBY_HOME='$rvm_rubies_path" "$rvm_path/config/system" > /dev/null; then
            if [[ -f "$rvm_path/config/system" ]]; then
                \rm -f "$rvm_path/config/system";
            fi;
        else
            source "$rvm_path/config/system";
        fi;
    fi;
    if (( ${rvm_default_flag:=0} == 1 )); then
        "$rvm_scripts_path/alias" delete default >&/dev/null;
        \find "${rvm_bin_path}" -maxdepth 0 -name 'default_*' -delete;
        \rm -f "$rvm_path/config/default";
        \rm -f "$rvm_environments_path/default";
        __rvm_rm_rf "$rvm_wrappers_path/default";
    fi;
    if (( ${rvm_verbose_flag:=0} == 1 )); then
        rvm_log "Now using system ruby.";
    fi;
    __rvm_remove_rvm_from_path;
    new_path="$PATH:${rvm_bin_path}";
    export rvm_ruby_string="system"
}
__rvm_using_gemset_globalcache ()
{
    "$rvm_scripts_path/db" "$rvm_user_path/db" "use_gemset_globalcache" | GREP_OPTIONS="" \grep '^true$' > /dev/null 2>&1;
    return $?
}
__rvm_version ()
{
    __rvm_meta;
    typeset IFS release;
    IFS=':';
    rvm_meta_authors="${rvm_meta_authors[*]}";
    rvm_meta_authors="${rvm_meta_authors//:/, }";
    echo -e "\nrvm ${rvm_meta_version} by ${rvm_meta_authors} [${rvm_meta_website}]\n"
}
__rvm_version_compare ()
{
    typeset first;
    first="$( printf "%b" "$1\n$3\n" | __rvm_version_sort | head -n1 )";
    case "$2" in
        -eq | == | =)
            [[ "$1" == "$3" ]] || return $?
        ;;
        -ne | !=)
            [[ "$1" != "$3" ]] || return $?
        ;;
        -gt | \>)
            [[ "$first" == "$3" && "$1" != "$3" ]] || return $?
        ;;
        -ge | \>=)
            [[ "$first" == "$3" || "$1" == "$3" ]] || return $?
        ;;
        -lt | \<)
            [[ "$first" == "$1" && "$1" != "$3" ]] || return $?
        ;;
        -le | \<=)
            [[ "$first" == "$1" || "$1" == "$3" ]] || return $?
        ;;
        *)
            rvm_error "Unsupported operator '$2'.";
            return 1
        ;;
    esac;
    return 0
}
__rvm_version_sort ()
{
    LC_ALL=C sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n
}
__rvm_wait_anykey ()
{
    if [[ -n "${1:-}" ]]; then
        echo "$1";
    fi;
    typeset _read_char_flag;
    if [[ -n "${ZSH_VERSION:-}" ]]; then
        _read_char_flag=k;
    else
        _read_char_flag=n;
    fi;
    builtin read -${_read_char_flag} 1 -s -r anykey
}
__rvm_which ()
{
    if command which --skip-alias --skip-functions which > /dev/null 2>&1; then
        command which --skip-alias --skip-functions "$@";
    else
        if command whence whence > /dev/null 2>&1; then
            command whence -p "$@";
        else
            if command which which > /dev/null 2>&1; then
                command which "$@";
            else
                if which which > /dev/null 2>&1; then
                    which "$@";
                else
                    return 1;
                fi;
            fi;
        fi;
    fi
}
__rvm_with ()
{
    ( __rvm_use "$1";
    shift;
    "$@" || return $? )
}
__rvmrc_full_path_to_file ()
{
    if [[ "$1" == "all.rvmrcs" || "$1" == "allGemfiles" ]]; then
        __rvmrc_warning_file="$1";
    else
        if [[ -d "$1" && -s "$1/.rvmrc" ]]; then
            __rvmrc_warning_file="$( __rvm_cd "$1" >/dev/null 2>&1; pwd )/.rvmrc";
        else
            if [[ -d "$1" && -s "$1/Gemfile" ]]; then
                __rvmrc_warning_file="$( __rvm_cd "$1" >/dev/null 2>&1; pwd )/Gemfile";
            else
                if [[ -f "$1" || "$1" =~ "*.rvmrc" || "$1" =~ "*Gemfile" ]]; then
                    __rvmrc_warning_file="$( dirname "$1" )";
                    : __rvmrc_warning_file:${__rvmrc_warning_file:=$PWD};
                    __rvmrc_warning_file="${__rvmrc_warning_file}/${1##*/}";
                else
                    rvm_warn "Do not know how to handle '$1', please report: http://bit.ly/rvm-issues ~ __rvmrc_full_path_to_file" 1>&2;
                    return 1;
                fi;
            fi;
        fi;
    fi
}
__rvmrc_warning ()
{
    typeset __rvmrc_warning_path __rvmrc_warning_file;
    __rvmrc_warning_path="$rvm_user_path/rvmrc_ignored";
    case "${1:-help}" in
        list)
            __rvmrc_warning_$1 "${2:-}" || return $?
        ;;
        check | check_quiet | ignore | reset)
            __rvmrc_full_path_to_file "${2:-}" && __rvmrc_warning_$1 "${__rvmrc_warning_file:-${2:-}}" || return $?
        ;;
        help)
            rvm_help rvmrc warning
        ;;
        *)
            rvm_error_help "Unknown subcommand '$1'" rvmrc warning;
            return 1
        ;;
    esac
}
__rvmrc_warning_check ()
{
    if __rvmrc_warning_check_quiet "$1"; then
        rvm_log "path '$1' is ignored.";
    else
        typeset ret=$?;
        rvm_log "path '$1' is not ignored.";
        return $ret;
    fi
}
__rvmrc_warning_check_quiet ()
{
    typeset __rvmrc_type;
    case "$1" in
        all.rvmrcs | allGemfiles)
            __rvmrc_type="${1#all}";
            __rvmrc_type="/${__rvmrc_type%s}"
        ;;
        *)
            __rvmrc_type="^all${1##*/}s"
        ;;
    esac;
    [[ -f "$__rvmrc_warning_path" ]] && {
        grep "^$1$" "$__rvmrc_warning_path" > /dev/null || grep "${__rvmrc_type}$" "$__rvmrc_warning_path" > /dev/null
    } || return $?
}
__rvmrc_warning_display_for_Gemfile ()
{
    typeset __rvmrc_warning_path __rvmrc_warning_file;
    __rvmrc_warning_path="$rvm_user_path/rvmrc_ignored";
    if [[ -t 2 ]] && __rvmrc_full_path_to_file "${1:-}" && ! __rvmrc_warning_check_quiet "${__rvmrc_warning_file:-${2:-}}"; then
        rvm_log "RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
you can ignore these warnings with 'rvm rvmrc warning ignore $1'.
To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.
" 1>&2;
    fi
}
__rvmrc_warning_display_for_rvmrc ()
{
    typeset __rvmrc_warning_path __rvmrc_warning_file;
    __rvmrc_warning_path="$rvm_user_path/rvmrc_ignored";
    if [[ -t 2 ]] && __rvmrc_full_path_to_file "${1:-}" && ! __rvmrc_warning_check_quiet "${__rvmrc_warning_file:-${2:-}}"; then
        rvm_warn "You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to [.]ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore $1',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
" 1>&2;
    fi
}
__rvmrc_warning_help ()
{
    rvm_log "Manage warning for .rvmrc files, usage:

    rvm rvmrc warning [check|check_quiet|help|ignore|list|reset] [<path>|all.rvmrcs|allGemfiles]
"
}
__rvmrc_warning_ignore ()
{
    __rvmrc_warning_check_quiet "$1" || case "$1" in
        all.rvmrcs | allGemfiles)
            echo "$1" >> "$__rvmrc_warning_path"
        ;;
        *)
            echo "$1" >> "$__rvmrc_warning_path"
        ;;
    esac
}
__rvmrc_warning_list ()
{
    rvm_log "# List of project files that ignore warnings:";
    if [[ -s "$__rvmrc_warning_path" ]]; then
        \cat "$__rvmrc_warning_path";
    fi
}
__rvmrc_warning_reset ()
{
    typeset __rvmrc_type;
    case "${1:-}" in
        all.rvmrcs | allGemfiles)
            if __rvmrc_warning_check_quiet "$1"; then
                __rvm_sed_i "$__rvmrc_warning_path" -e "/^${1//\//\/}\$/ d" -e '/^$/ d';
                __rvmrc_type="${1#all}";
                __rvmrc_type="${__rvmrc_type%s}";
                __rvm_sed_i "$__rvmrc_warning_path" -e "/\/${__rvmrc_type//\//\/}\$/ d" -e '/^$/ d';
            else
                rvm_debug "Already removed warning ignore from '$1'.";
            fi
        ;;
        *)
            if __rvmrc_warning_check_quiet "$1"; then
                __rvm_sed_i "$__rvmrc_warning_path" -e "/^${1//\//\/}\$/ d" -e '/^$/ d';
            else
                rvm_debug "Already removed warning ignore from '$1'.";
            fi
        ;;
    esac
}
__variables_definition ()
{
    typeset -a __variables_list __array_list;
    typeset __method;
    __method="$1";
    __variables_list=(rvm_head_flag rvm_ruby_selected_flag rvm_user_install_flag rvm_path_flag rvm_cron_flag rvm_static_flag rvm_default_flag rvm_loaded_flag rvm_llvm_flag rvm_skip_autoreconf_flag rvm_18_flag rvm_19_flag rvm_20_flag rvm_force_autoconf_flag rvm_dump_environment_flag rvm_verbose_flag rvm_debug_flag rvm_trace_flag __array_start rvm_pretty_print_flag rvm_create_flag rvm_remove_flag rvm_movable_flag rvm_gemdir_flag rvm_reload_flag rvm_auto_reload_flag rvm_disable_binary_flag rvm_ignore_gemsets_flag rvm_skip_gemsets_flag rvm_install_on_use_flag rvm_remote_flag rvm_verify_downloads_flag rvm_skip_openssl_flag rvm_gems_cache_path rvm_gems_path rvm_man_path rvm_ruby_gem_path rvm_ruby_log_path rvm_gems_cache_path rvm_archives_path rvm_docs_path rvm_environments_path rvm_examples_path rvm_gems_path rvm_gemsets_path rvm_help_path rvm_hooks_path rvm_lib_path rvm_log_path rvm_patches_path rvm_repos_path rvm_rubies_path rvm_scripts_path rvm_src_path rvm_tmp_path rvm_user_path rvm_usr_path rvm_wrappers_path rvm_externals_path rvm_stored_errexit rvm_ruby_strings rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_repo_branch rvm_ruby_revision rvm_ruby_tag rvm_ruby_sha rvm_ruby_version rvm_ruby_package_file rvm_ruby_name rvm_ruby_name rvm_ruby_args rvm_ruby_user_tag rvm_ruby_patch detected_rvm_ruby_name __rvm_env_loaded next_token rvm_error_message rvm_gemset_name rvm_parse_break rvm_token rvm_action rvm_export_args rvm_gemset_separator rvm_expanding_aliases rvm_tar_command rvm_tar_options rvm_patch_original_pwd rvm_project_rvmrc rvm_archive_extension rvm_autoinstall_bundler_flag rvm_codesign_identity rvm_expected_gemset_name rvm_with_gems rvm_without_gems rvm_ignore_dotfiles_flag rvm_latest_binary_flag rvm_fuzzy_flag rvm_autolibs_flag rvm_autolibs_flag_number rvm_autolibs_flag_runner rvm_quiet_curl_flag rvm_max_time_flag rvm_error_clr rvm_warn_clr rvm_debug_clr rvm_notify_clr rvm_reset_clr rvm_error_color rvm_warn_color rvm_debug_color rvm_notify_color rvm_reset_color);
    __array_list=(rvm_patch_names rvm_ree_options rvm_autoconf_flags rvm_architectures);
    case "${__method}" in
        export)
            export -a "${__array_list[@]}"
        ;;
        unset)
            unset "${__array_list[@]}"
        ;;
        *)
            rvm_error "Unknown action given to __variables_definition: ${__method}";
            return 1
        ;;
    esac;
    ${__method} "${__variables_list[@]}"
}
_maglev_gemstone ()
{
    case "$1" in
        start)
            export MAGLEV_HOME="$rvm_ruby_home";
            export GEMSTONE_GLOBAL_DIR=$MAGLEV_HOME;
            if [[ -x "$MAGLEV_HOME/gemstone/bin/gslist" ]]; then
                if "$MAGLEV_HOME/gemstone/bin/gslist" -clv > /dev/null 2>&1; then
                    true;
                else
                    "$rvm_ruby_home/bin/maglev" start;
                fi;
            fi
        ;;
    esac
}
cd ()
{
    if builtin cd "$@"; then
        [[ -n "${rvm_current_rvmrc:-}" && "$*" == "." ]] && rvm_current_rvmrc="" || true;
        __rvm_cd_functions_set;
        return 0;
    else
        return $?;
    fi
}
file_exists_at_url ()
{
    ( if [[ -n "${1:-}" ]]; then
        unset curl;
        \curl --silent --insecure --location --list-only --max-time ${rvm_max_time_flag:-3} --head "$1" 2>&1 | GREP_OPTIONS="" \grep -E 'HTTP/[0-9\.]+ 200 OK' > /dev/null 2>&1 || {
            typeset __ret=$?;
            case ${__ret} in
                28)
                    rvm_warn "RVM was not able to check existence of remote files with timeout of ${rvm_max_time_flag:-3} seconds
you can increase the timeout by setting it in ~/.rvmrc => rvm_max_time_flag=10"
                ;;
            esac;
            return ${__ret}
        };
    else
        rvm_warn "Warning: URL was not passed to file_exists_at_url";
        return 1;
    fi )
}
gem ()
{
    typeset result;
    ( typeset rvmrc;
    rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc");
    if [[ -n "${rvm_prefix:-}" ]] && ! [[ "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]; then
        rvm_rvmrc_files+=("${rvm_prefix}/.rvmrc");
    fi;
    for rvmrc in "${rvm_rvmrc_files[@]}";
    do
        [[ -s "${rvmrc}" ]] && source "${rvmrc}" || true;
    done;
    unset rvm_rvmrc_files;
    command gem "$@" ) || result=$?;
    hash -r;
    return ${result:-0}
}
is_a_function ()
{
    typeset -f $1 > /dev/null 2>&1 || return $?
}
is_parent_of ()
{
    typeset name pid ppid pname;
    name=$1;
    pid=$2;
    while [[ -n "$pid" && "$pid" != "0" ]]; do
        read ppid pname < <(ps -p $pid -o ppid= -o comm=);
        if [[ -n "$ppid" && -n "$pname" ]]; then
            if [[ "$pname" == "$name" ]]; then
                echo $pid;
                return 0;
            else
                pid=$ppid;
            fi;
        else
            break;
        fi;
    done;
    return 1
}
popd ()
{
    if builtin popd "$@"; then
        [[ -n "${rvm_current_rvmrc:-}" && "$*" == "." ]] && rvm_current_rvmrc="" || true;
        __rvm_cd_functions_set;
        return 0;
    else
        return $?;
    fi
}
printenv_null ()
{
    if printenv --null > /dev/null 2> /dev/null; then
        printenv --null;
    else
        printenv | sed '/=/ { s/=.*$//; p; }; d;' | while read name; do
            zero="\0";
            eval "eval \"printf '%b' '$name=\$$name$zero'\"";
        done;
    fi
}
pushd ()
{
    if builtin pushd "$@"; then
        [[ -n "${rvm_current_rvmrc:-}" && "$*" == "." ]] && rvm_current_rvmrc="" || true;
        __rvm_cd_functions_set;
        return 0;
    else
        return $?;
    fi
}
rubygems_detect_ruby_lib_gem_path ()
{
    typeset ruby_path="$( __rvm_which "${1:-ruby}" )";
    while [[ -L "$ruby_path" ]]; do
        ruby_path="$( readlink "$ruby_path" )";
    done;
    ruby_lib_gem_path="$( "$ruby_path" -rrubygems -e 'puts Gem.default_dir' 2>/dev/null )";
    [[ -n "$ruby_lib_gem_path" ]] || rubygems_detect_ruby_lib_gem_path_fallback || return $?
}
rubygems_detect_ruby_lib_gem_path_fallback ()
{
    rubygems_detect_ruby_lib_gem_path_from "rubylib" || rubygems_detect_ruby_lib_gem_path_from "lib" || return $?;
    ruby_lib_gem_path+="/gems";
    typeset ruby_version;
    ruby_version="$( __rvm_ruby_config_get ruby_version "$ruby_path")";
    if [[ -d "${ruby_lib_gem_path}/$ruby_version" ]]; then
        ruby_lib_gem_path+="$ruby_version";
    else
        if [[ -d "${ruby_lib_gem_path}/shared" ]]; then
            ruby_lib_gem_path+="shared";
        else
            return 3;
        fi;
    fi
}
rubygems_detect_ruby_lib_gem_path_from ()
{
    ruby_lib_gem_path="$( __rvm_ruby_config_get ${1}prefix "$ruby_path" )";
    [[ -z "${ruby_lib_gem_path:-}" ]] || {
        ruby_lib_gem_path="$( __rvm_ruby_config_get ${1}dir    "$ruby_path" )";
        ruby_lib_gem_path="${ruby_lib_gem_path%/*}"
    };
    [[ -n "${ruby_lib_gem_path:-}" ]] || return 1;
    [[ -d "${ruby_lib_gem_path}/gems" ]] || return 2
}
rvm ()
{
    if __rvm_has_opt "posix"; then
        echo "RVM can not be run with \`set -o posix\`, please turn it off and try again.";
        return 100;
    fi;
    typeset result current_result;
    export -a rvm_ruby_args > /dev/null 2> /dev/null;
    rvm_ruby_args=();
    if (( ${rvm_ignore_rvmrc:=0} == 0 )); then
        [[ -n "${rvm_stored_umask:-}" ]] || export rvm_stored_umask=$(umask);
        rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc");
        if [[ -n "${rvm_prefix:-}" ]] && [[ ! "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]; then
            rvm_rvmrc_files+=("${rvm_prefix}/.rvmrc");
        fi;
        for rvmrc in "${rvm_rvmrc_files[@]}";
        do
            if [[ -f "$rvmrc" ]]; then
                if GREP_OPTIONS="" \grep '^\s*rvm .*$' "$rvmrc" > /dev/null 2>&1; then
                    printf "%b" "
Error:
        $rvmrc is for rvm settings only.
        rvm CLI may NOT be called from within $rvmrc.
        Skipping the loading of $rvmrc";
                    return 1;
                else
                    source "$rvmrc";
                fi;
            fi;
        done;
        unset rvm_rvmrc_files;
    fi;
    disk_version="$(\cat "$rvm_path/VERSION") ($(\cat "$rvm_path/RELEASE" 2>/dev/null))";
    if [[ -s "$rvm_path/VERSION" && "${rvm_version:-}" != "${disk_version:-}" && "reload" != "${1:-}" ]]; then
        if (( ${rvm_auto_reload_flag:-0} )); then
            __rvm_project_rvmrc_lock=0;
            rvm_reload_flag=1;
            source "${rvm_scripts_path:-${rvm_path}/scripts}/rvm";
        else
            printf "%b" "
A RVM version ${disk_version} is installed yet ${rvm_version} is loaded.
Please do one of the following:
  * 'rvm reload'
  * open a new shell
  * 'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg.
  * 'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.

";
            return 1;
        fi;
    fi;
    __rvm_initialize;
    __rvm_setup;
    __rvm_path_match_gem_home_check;
    next_token="$1";
    (( $# == 0 )) || shift;
    __rvm_parse_args "$@";
    (( rvm_trace_flag == 0 )) || {
        export PS4;
        if [[ -n "$ZSH_VERSION" ]]; then
            PS4="%F{red}%x:%I %F{green}%N:%i%F{white} %_";
        else
            PS4="+ \$(date \"+%s.%N\") \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()}  \${LINENO} > ";
        fi;
        set -x
    };
    result=$?;
    : rvm_ruby_args:${#rvm_ruby_args[@]}:${rvm_ruby_args[*]}:;
    (( result )) || case "${rvm_action:=help}" in
        use)
            if rvm_is_a_shell_function; then
                __rvm_use && __rvm_use_ruby_warnings;
            fi
        ;;
        switch)
            if rvm_is_a_shell_function; then
                __rvm_switch "${rvm_ruby_args[@]}";
            fi
        ;;
        srcdir)
            __rvm_source_dir
        ;;
        inspect | strings | version)
            __rvm_${rvm_action}
        ;;
        ls | list)
            "$rvm_scripts_path/list" "${rvm_ruby_args[@]}"
        ;;
        debug)
            rvm_is_not_a_shell_function="${rvm_is_not_a_shell_function}" "$rvm_scripts_path/info" '' debug
        ;;
        info)
            rvm_is_not_a_shell_function="${rvm_is_not_a_shell_function}" "$rvm_scripts_path/${rvm_action}" "${rvm_ruby_args[@]}"
        ;;
        benchmark | reset)
            source "$rvm_scripts_path/functions/${rvm_action}";
            __rvm_${rvm_action}
        ;;
        update)
            printf "%b" "ERROR: rvm update has been removed. See 'rvm get' and rvm 'rubygems' CLI API instead\n"
        ;;
        reboot)
            source "$rvm_scripts_path/functions/cleanup";
            __rvm_reboot
        ;;
        implode | seppuku)
            source "$rvm_scripts_path/functions/implode";
            __rvm_implode
        ;;
        get)
            next_token="${1:-}";
            (( $# == 0 )) || shift;
            [[ "$next_token" == "${rvm_action}" ]] && shift;
            tmpdir="${TMPDIR:-/tmp}";
            \cp -f "$rvm_scripts_path/get" "$tmpdir/$$";
            if bash "$tmpdir/$$" "${rvm_ruby_args[@]}"; then
                rvm_reload_flag=1;
            else
                rvm_error "Could not update RVM, get some help at #rvm IRC channel at freenode servers.";
            fi;
            \rm -f $tmpdir/$$
        ;;
        current)
            __rvm_env_string
        ;;
        help | rtfm | env | list | monitor | notes | pkg | requirements)
            next_token="${1:-}";
            (( $# == 0 )) || shift;
            if (( $# )) && [[ "$next_token" == "${rvm_action}" ]]; then
                shift;
            fi;
            "$rvm_scripts_path/${rvm_action}" "${rvm_ruby_args[@]}"
        ;;
        cleanup | tools | snapshot | disk-usage | repair | alias | docs | rubygems | migrate | cron | group)
            __rvm_run_script "$rvm_action" "${rvm_ruby_args[@]}"
        ;;
        upgrade)
            __rvm_fix_selected_ruby __rvm_run_wrapper "$rvm_action" "$rvm_action" "${rvm_ruby_args[@]}"
        ;;
        autolibs | osx-ssl-certs | fix-permissions)
            __rvm_run_wrapper "$rvm_action" "$rvm_action" "${rvm_ruby_args[@]}"
        ;;
        wrapper)
            "$rvm_scripts_path/wrapper" "$rvm_ruby_string" "$rvm_wrapper_name" "${rvm_ruby_args[@]}";
            result=$?;
            unset rvm_wrapper_name
        ;;
        do)
            old_rvm_ruby_string=${rvm_ruby_string:-};
            unset rvm_ruby_string;
            export rvm_ruby_strings;
            ( if [[ -n "${rvm_in_flag}" && -d "${rvm_in_flag}" ]]; then
                __rvm_cd "${rvm_in_flag}";
            fi;
            "$rvm_scripts_path/set" "$rvm_action" "${rvm_ruby_args[@]}" );
            result=$?;
            [[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string;
            unset old_rvm_ruby_string
        ;;
        rvmrc)
            __rvm_rvmrc_tools "${rvm_ruby_args[@]}"
        ;;
        config-get)
            typeset __ruby __var;
            __ruby=$( __rvm_which ruby );
            for __var in "${rvm_ruby_args[@]}";
            do
                __rvm_ruby_config_get "${__var}" "${__ruby}";
            done
        ;;
        gemset_use)
            if rvm_is_a_shell_function; then
                __rvm_gemset_use;
            fi
        ;;
        gemset)
            export rvm_ruby_strings;
            "$rvm_scripts_path/gemsets" "${rvm_ruby_args[@]}";
            result=$?;
            rvm_ruby_strings="";
            if rvm_is_a_shell_function no_warning; then
                if [[ ${rvm_delete_flag:-0} -eq 1 ]]; then
                    if [[ "${GEM_HOME:-""}" == "${GEM_HOME%%${rvm_gemset_separator:-@}*}${rvm_gemset_separator:-@}${rvm_gemset_name}" ]]; then
                        rvm_delete_flag=0;
                        __rvm_use "@default";
                    fi;
                    unset gem_prefix;
                else
                    if [[ "${rvm_ruby_args[*]}" =~ ^rename ]]; then
                        typeset _command _from _to;
                        read _command _from _to <<< "${rvm_ruby_args[*]}";
                        if [[ "${GEM_HOME:-""}" == "${GEM_HOME%%${rvm_gemset_separator:-@}*}${rvm_gemset_separator:-@}${_from}" ]]; then
                            __rvm_use "@${_to}";
                        fi;
                    fi;
                fi;
            fi
        ;;
        reload)
            rvm_reload_flag=1
        ;;
        tests | specs)
            rvm_action="rake";
            __rvm_do
        ;;
        remove)
            export rvm_path;
            if [[ -n "${rvm_ruby_strings}" ]]; then
                __rvm_run_wrapper manage "$rvm_action" "${rvm_ruby_strings//*-- }";
            else
                __rvm_run_wrapper manage "$rvm_action";
            fi;
            __rvm_use default
        ;;
        fetch | uninstall | reinstall)
            export rvm_path;
            if [[ -n "${rvm_ruby_strings}" ]]; then
                __rvm_run_wrapper manage "$rvm_action" "${rvm_ruby_strings//*-- }";
            else
                __rvm_run_wrapper manage "$rvm_action";
            fi
        ;;
        try_install | install)
            export rvm_path;
            if [[ -n "${rvm_ruby_strings}" ]]; then
                typeset save_ruby;
                selected_ruby="$( __rvm_select && echo $rvm_env_string )";
                if [[ -z "${selected_ruby}" ]]; then
                    rvm_error "Could not detect ruby version/name for installation, please be more specific.";
                    false;
                else
                    if (( ${rvm_force_flag:-0} == 0 )) && "$rvm_scripts_path"/list strings | GREP_OPTIONS="" \grep "^${selected_ruby%${rvm_gemset_separator:-'@'}*}$" > /dev/null; then
                        rvm_log "Already installed ${selected_ruby%${rvm_gemset_separator:-'@'}*}.
To reinstall use:

    rvm reinstall ${rvm_ruby_strings}
";
                    else
                        __rvm_run_wrapper manage install "${rvm_ruby_strings}";
                    fi;
                fi;
            else
                rvm_error "Can not use or install 'all' rubies.";
                false;
            fi
        ;;
        mount | automount | prepare)
            if [[ -n "$rvm_ruby_string" ]]; then
                rvm_ruby_args=("$rvm_ruby_string" "${rvm_ruby_args[@]}");
            fi;
            "${rvm_scripts_path}/external" "$rvm_action" "${rvm_ruby_args[@]}"
        ;;
        export)
            __rvm_export "$rvm_export_args"
        ;;
        unexport)
            __rvm_unset_exports
        ;;
        error)
            false
        ;;
        answer)
            source "$rvm_scripts_path/functions/fun";
            __rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything;
            result=42
        ;;
        question)
            source "$rvm_scripts_path/functions/fun";
            __rvm_ultimate_question;
            result=42
        ;;
        which)
            __rvm_which "${rvm_ruby_args[@]}"
        ;;
        *)
            rvm_error "unknown action '$rvm_action'";
            false
        ;;
    esac;
    current_result=$?;
    (( result )) || result=${current_result};
    (( result )) || case "$rvm_action" in
        reinstall | try_install | install)
            if [[ $(\find $rvm_rubies_path -maxdepth 1 -mindepth 1 -type d 2>/dev/null | wc -l) -eq 1 ]] && [[ ! -f "${rvm_environments_path}/default" ]] && rvm_is_a_shell_function no_warning; then
                rvm_log "";
                rvm_verbose_flag=0 rvm_default_flag=1 __rvm_use;
            fi
        ;;
    esac;
    current_result=$?;
    (( result )) || result=${current_result};
    typeset __local_rvm_trace_flag;
    __local_rvm_trace_flag=${rvm_trace_flag:-0};
    if [[ ${rvm_reload_flag:-0} -eq 1 ]]; then
        if [[ -s "$rvm_scripts_path/rvm" ]]; then
            __rvm_project_rvmrc_lock=0;
            source "$rvm_scripts_path/rvm";
        else
            echo "rvm not found in $rvm_path, please install and run 'rvm reload'";
            __rvm_teardown;
        fi;
    else
        __rvm_teardown;
    fi;
    if (( __local_rvm_trace_flag > 0 )); then
        set +o verbose;
        set +o xtrace;
        [[ -n "${ZSH_VERSION:-""}" ]] || set +o errtrace;
    fi;
    return ${result:-0}
}
rvm_debug ()
{
    (( ${rvm_debug_flag:-0} )) || return 0;
    if rvm_pretty_print stderr; then
        printf "%b" "${rvm_debug_clr:-}$*${rvm_reset_clr:-}\n";
    else
        printf "%b" "$*\n";
    fi 1>&2
}
rvm_debug_stream ()
{
    (( ${rvm_debug_flag:-0} || ${rvm_trace_flag:-0} )) || return 0;
    if rvm_pretty_print stdout; then
        \cat - | awk '{print "'"${rvm_debug_clr:-}"'"$0"'"${rvm_reset_clr:-}"'"}';
    else
        \cat -;
    fi 1>&2
}
rvm_error ()
{
    if rvm_pretty_print stderr; then
        printf "%b" "${rvm_error_clr:-}$*${rvm_reset_clr:-}\n";
    else
        printf "%b" "$*\n";
    fi 1>&2
}
rvm_error_help ()
{
    rvm_error "$1";
    shift;
    rvm_help "$@"
}
rvm_fail ()
{
    rvm_error "$1";
    exit "${2:-1}"
}
rvm_help ()
{
    "${rvm_scripts_path}/help" "$@"
}
rvm_is_a_shell_function ()
{
    typeset _message;
    if (( ${rvm_is_not_a_shell_function:-0} )) && [[ "${1:-}" != "no_warning" ]]; then
        if rvm_pretty_print stderr; then
            rvm_log "";
        fi;
        if rvm_pretty_print stderr; then
            rvm_log "RVM is not a function, selecting rubies with '${rvm_error_clr:-}rvm use ...${rvm_notify_clr:-}' will not work." 1>&2;
        else
            rvm_error "RVM is not a function, selecting rubies with 'rvm use ...' will not work.";
        fi;
        rvm_warn '
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
';
    fi;
    return ${rvm_is_not_a_shell_function:-0}
}
rvm_log ()
{
    if rvm_pretty_print stdout; then
        printf "%b" "${rvm_notify_clr:-}$*${rvm_reset_clr:-}\n";
    else
        printf "%b" "$*\n";
    fi
}
rvm_out ()
{
    printf "$*\n"
}
rvm_pretty_print ()
{
    case "${rvm_pretty_print_flag:=auto}" in
        0 | no)
            return 1
        ;;
        1 | auto)
            case "${TERM:-dumb}" in
                dumb | unknown)
                    return 1
                ;;
            esac;
            case "$1" in
                stdout)
                    [[ -t 1 ]] || return 1
                ;;
                stderr)
                    [[ -t 2 ]] || return 1
                ;;
                [[:digit:]])
                    [[ -t $1 ]] || return 1
                ;;
                any)
                    [[ -t 1 || -t 2 ]] || return 1
                ;;
                *)
                    [[ -t 1 && -t 2 ]] || return 1
                ;;
            esac;
            return 0
        ;;
        2 | force)
            return 0
        ;;
    esac
}
rvm_warn ()
{
    if rvm_pretty_print stdout; then
        printf "%b" "${rvm_warn_clr:-}$*${rvm_reset_clr:-}\n";
    else
        printf "%b" "$*\n";
    fi
}
update_terminal_cwd ()
{
    local SEARCH=' ';
    local REPLACE='%20';
    local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}";
    printf '\e]7;%s\a' "$PWD_URL"
} and  *after* setting the new value
pass old value to set/nx listeners
docs
dont pass model as argument to listeners (bind instead), add tests for oldValue in set/nx calbacks
v bump