Skip to content

@mabonyi /gist:2591552
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
( export 'PS4=+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > ' ; set -v ; rvm --trace info rvm )
03:41:37 rug@leviathan:~ ruby-1.9.3-p194
$ ( export 'PS4=+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > ' ; set -v ; rvm --trace info rvm )
rvm_project_rvmrc=1
rvm_trust_rvmrcs_flag=1
rvm_gem_options="--no-rdoc --no-ri"
rvm_path=/usr/local/rvm
rvm_pretty_print_flag=1
rvm_auto_reload_flag=1
rvm_ps1=1
#rvm_stored_umask=0000
umask g+w
cat "$rvm_path/VERSION"
cat "$rvm_path/RELEASE" 2>/dev/null
#!/usr/bin/env bash
# Base is a collection of general files + commonly included setup functions.
: rvm_trace_flag:${rvm_trace_flag:=0}
if (( rvm_trace_flag > 0 ))
then
set -o xtrace
# set -o errexit
if [[ -z "${ZSH_VERSION:-}" ]]
then
# set -o errtrace
# set -o pipefail
export PS4
PS4="+ \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > "
fi
elif [[ ${rvm_debug_flag:-0} > 0 ]]
then
rvm_debug_flag=0
fi
export __array_start rvm_path >/dev/null
#
# Setup environment parameters.
#
if [[ -n "${ZSH_VERSION:-}" ]]
then
__array_start=1
else
__array_start=0
fi
if (( ${rvm_ignore_rvmrc:=0} == 0 ))
then
: rvm_stored_umask:${rvm_stored_umask:=$(umask)}
for rvmrc in /etc/rvmrc "$HOME/.rvmrc"
do
if [[ -f "$rvmrc" ]]
then
if GREP_OPTIONS="" \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1
then
printf "%b" "
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
fi
rvm_project_rvmrc=1
rvm_trust_rvmrcs_flag=1
rvm_gem_options="--no-rdoc --no-ri"
rvm_path=/usr/local/rvm
rvm_pretty_print_flag=1
rvm_auto_reload_flag=1
rvm_ps1=1
#rvm_stored_umask=0000
umask g+w
export rvm_path
if [[ -z "${rvm_path:-}" ]]
then
if (( UID == 0 )) && [[ -d "/usr/local/rvm" ]]
then rvm_path="/usr/local/rvm"
elif [[ -d "${HOME}/.rvm" ]]
then rvm_path="${HOME}/.rvm"
elif [[ -d "/usr/local/rvm" ]]
then rvm_path="/usr/local/rvm"
else echo "Can't find rvm install!" 1>&2 ; exit 1
fi
fi
true ${rvm_scripts_path:="$rvm_path/scripts"}
# Initialize all main RVM variables.
source "$rvm_scripts_path/initialize"
#!/usr/bin/env bash
: rvm_trace_flag:${rvm_trace_flag:=0}
if (( rvm_trace_flag > 0 ))
then
set -o xtrace
# set -o errexit
if [[ -z "${ZSH_VERSION:-}" ]]
then
# set -o errtrace
# set -o pipefail
export PS4
PS4="+ \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > "
fi
elif [[ ${rvm_debug_flag:-0} > 0 ]]
then
rvm_debug_flag=0
fi
# Set shell options that RVM cannot live without,
# see __rvm_setup and __rvm_teardown for further settings.
if [[ -n "${BASH_VERSION:-}" ]]
then
shopt -s extglob
elif [[ -n "${ZSH_VERSION:-}" ]]
then
setopt extendedglob
setopt kshglob
setopt no_glob_subst
else
printf "%b" "What the heck kind of shell are you running here???\n"
fi
export __rvm_env_loaded
# set env loaded flag if not yet set
: __rvm_env_loaded:${__rvm_env_loaded:=0}:
# increase load count counter
: __rvm_env_loaded:$(( __rvm_env_loaded+=1 )):
# load only if not yet loaded or first time loading
if [[ -z "${rvm_tmp_path:-}" ]] || (( __rvm_env_loaded == 1 ))
then
if typeset -f __rvm_cleanse_variables >/dev/null 2>&1
then
__rvm_cleanse_variables
fi
# Ensure that /etc/rvmrc and $HOME/.rvmrc values take precedence.
if (( ${rvm_ignore_rvmrc:=0} == 0 ))
then
: rvm_stored_umask:${rvm_stored_umask:=$(umask)}
for rvmrc in /etc/rvmrc "$HOME/.rvmrc"
do
if [[ -f "$rvmrc" ]]
then
if GREP_OPTIONS="" \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1
then
printf "%b" "
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
fi
export rvm_path
if [[ -z "${rvm_path:-}" ]]
then
if (( UID == 0 )) && [[ -d "/usr/local/rvm" ]]
then rvm_path="/usr/local/rvm"
elif [[ -d "${HOME}/.rvm" ]]
then rvm_path="${HOME}/.rvm"
elif [[ -d "/usr/local/rvm" ]]
then rvm_path="/usr/local/rvm"
else echo "Can't find rvm install!" 1>&2 ; exit 1
fi
fi
true ${rvm_scripts_path:="$rvm_path/scripts"}
#
# Setup RVM Environment variables. Each RVM internal path is intended to be
# configurable by the end users for whatever their needs may be.
# They should be set in /etc/rvmrc and then $HOME/.rvmrc
#
if [[ -z "${rvm_user_install_flag:-}" ]]
then
export rvm_user_install_flag rvm_man_path
if (( UID == 0 )) ||
[[ -n "${rvm_prefix:-}" && "${rvm_prefix:-}" != "${HOME}" ]]
then
true "${rvm_man_path:="${rvm_prefix}/share/man"}"
rvm_user_install_flag=0
else
rvm_user_install_flag=1
fi
fi
: \
rvm_bin_path:${rvm_bin_path:="$rvm_path/bin"} \
rvm_man_path:${rvm_man_path:="$rvm_path/man"} \
rvm_archives_path:${rvm_archives_path:="$rvm_path/archives"} \
rvm_docs_path:${rvm_docs_path:="$rvm_path/docs"} \
rvm_environments_path:${rvm_environments_path:="$rvm_path/environments"} \
rvm_examples_path:${rvm_examples_path:="$rvm_path/examples"} \
rvm_gems_path:${rvm_gems_path:="$rvm_path/gems"} \
rvm_gemsets_path:${rvm_gemsets_path:="$rvm_path/gemsets"} \
rvm_help_path:${rvm_help_path:="$rvm_path/help"} \
rvm_hooks_path:${rvm_hooks_path:="$rvm_path/hooks"} \
rvm_lib_path:${rvm_lib_path:="$rvm_path/lib"} \
rvm_log_path:${rvm_log_path:="$rvm_path/log"} \
rvm_patches_path:${rvm_patches_path:="$rvm_path/patches"} \
rvm_repos_path:${rvm_repos_path:="$rvm_path/repos"} \
rvm_rubies_path:${rvm_rubies_path:="$rvm_path/rubies"} \
rvm_externals_path:${rvm_externals_path:="$rvm_path/externals"} \
rvm_rubygems_path:${rvm_rubygems_path:="$rvm_path/rubygems"} \
rvm_src_path:${rvm_src_path:="$rvm_path/src"} \
rvm_tmp_path:${rvm_tmp_path:="$rvm_path/tmp"} \
rvm_user_path:${rvm_user_path:="$rvm_path/user"} \
rvm_usr_path:${rvm_usr_path:="$rvm_path/usr"} \
rvm_wrappers_path:${rvm_wrappers_path:="$rvm_path/wrappers"} \
rvm_verbose_flag:${rvm_verbose_flag:=0} \
rvm_debug_flag:${rvm_debug_flag:=0} \
rvm_gems_cache_path:${rvm_gems_cache_path:=${rvm_gems_path:-"$rvm_path/gems"}/cache}
export rvm_action rvm_alias_expanded rvm_archive_extension rvm_archives_path rvm_bin_flag rvm_bin_path rvm_configure_flags rvm_debug_flag rvm_default_flag rvm_delete_flag rvm_docs_path rvm_docs_type rvm_dump_environment_flag rvm_environments_path rvm_error_message rvm_examples_path rvm_expanding_aliases rvm_file_name rvm_gemdir_flag rvm_gems_cache_path rvm_gems_path rvm_gemset_name rvm_gemset_separator rvm_gemsets_path rvm_gemstone_package_file rvm_gemstone_url rvm_head_flag rvm_help_path rvm_hook rvm_hooks_path rvm_install_args rvm_install_on_use_flag rvm_lib_path rvm_llvm_flag rvm_loaded_flag rvm_log_path rvm_make_flags rvm_niceness rvm_nightly_flag rvm_only_path_flag rvm_parse_break rvm_patch_names rvm_patch_original_pwd rvm_patches_path rvm_path rvm_pretty_print_flag rvm_proxy rvm_quiet_flag rvm_ree_options rvm_reload_flag rvm_remove_flag rvm_repos_path rvm_rubies_path rvm_ruby_alias rvm_ruby_aliases 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_load_path 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_require 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_scripts_path rvm_sdk rvm_user_install_flag rvm_silent_flag rvm_src_path rvm_sticky_flag rvm_system_flag rvm_tmp_path rvm_token rvm_trace_flag rvm_use_flag rvm_user_flag rvm_user_path rvm_usr_path rvm_verbose_flag rvm_wrapper_name rvm_wrappers_path rvm_ruby_repo_branch rvm_man_path rvm_architectures
fi # if [[ -z "${rvm_tmp_path:-}" ]] || (( __rvm_env_loaded == 1 ))
rvm_project_rvmrc=1
rvm_trust_rvmrcs_flag=1
rvm_gem_options="--no-rdoc --no-ri"
rvm_path=/usr/local/rvm
rvm_pretty_print_flag=1
rvm_auto_reload_flag=1
rvm_ps1=1
#rvm_stored_umask=0000
umask g+w
rvm_project_rvmrc=1
rvm_trust_rvmrcs_flag=1
rvm_gem_options="--no-rdoc --no-ri"
rvm_path=/usr/local/rvm
rvm_pretty_print_flag=1
rvm_auto_reload_flag=1
rvm_ps1=1
#rvm_stored_umask=0000
umask g+w
rvm_project_rvmrc=1
rvm_trust_rvmrcs_flag=1
rvm_gem_options="--no-rdoc --no-ri"
rvm_path=/usr/local/rvm
rvm_pretty_print_flag=1
rvm_auto_reload_flag=1
rvm_ps1=1
#rvm_stored_umask=0000
umask g+w
# Load the general scripts.
# Use rvm_base_except="selector", for example, to override the loading.
case " ${rvm_base_except:-} " in
(*[[:space:]]selector[[:space:]]*)
true # do not load.
;;
(*)
source "$rvm_scripts_path/selector"
source "$rvm_scripts_path/selector_gemsets"
;;
esac
#!/usr/bin/env bash
# __rvm_select implementation version patch_level
__rvm_select()
{
true ${rvm_gemset_name:=}
typeset _original_env_string
_original_env_string=${rvm_env_string}
# Set Variable Defaults
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_configure_flags 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_args rvm_install_on_use_flag rvm_llvm_flag rvm_loaded_flag rvm_make_flags rvm_niceness rvm_nightly_flag rvm_only_path_flag rvm_parse_break rvm_patch_names rvm_patch_original_pwd rvm_pretty_print_flag rvm_proxy rvm_quiet_flag rvm_ree_options rvm_reload_flag rvm_remove_flag rvm_ruby_alias rvm_ruby_aliases 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_load_path 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_require 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_architectures
if [[ -z "${rvm_ruby_string:-}" ]]
then # First we build rvm_ruby_string from components if it is empty.
if [[ -n "${rvm_ruby_interpreter:-}" ]]
then
rvm_ruby_string="$rvm_ruby_interpreter"
fi
if [[ -n "${rvm_ruby_version:-}" ]]
then
rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_version"
fi
if [[ -n "${rvm_ruby_patch_level:-}" ]]
then
rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_patch_level"
fi
if [[ -n "${rvm_ruby_revision:-}" ]]
then
rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_revision"
fi
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" in
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"
elif [[ "nightly" == "${rvm_ruby_version:-}" ]]
then
__rvm_db "macruby_nightly_url" "rvm_ruby_url"
rvm_ruby_package_name="${rvm_ruby_interpreter}_nightly-${rvm_ruby_version}"
rvm_ruby_package_file="$rvm_ruby_package_name"
elif [[ -n "${rvm_ruby_version:-}" ]]
then
__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
rvm_ruby_patch_level=""
else
rvm_error "MacRuby can only be installed on a Darwin OS."
fi
;;
rbx|rubinius)
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")}
rvm_ruby_patch_level=""
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
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"
else
rvm_ruby_version="head"
fi
if [[ -n "${rvm_rbx_opt:-}" ]]
then
export RBXOPT="${RBXOPT:=${rvm_rbx_opt}}"
fi
;;
jruby)
rvm_ruby_patch_level=""
if (( ${rvm_head_flag:=0} == 1 ))
then
rvm_ruby_version="head"
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")}"
elif [[ -n ${rvm_configure_flags:-} ]]
then
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_ruby_version="${rvm_ruby_version:-"$(__rvm_db "jruby_version")"}"
rvm_ruby_tag="${rvm_ruby_tag:-${rvm_ruby_version}}"
else
rvm_archive_extension="tar.gz"
rvm_ruby_version="${rvm_ruby_version:-"$(__rvm_db "jruby_version")"}"
jruby_url="$(__rvm_db "jruby_url")"
rvm_ruby_package_file="${rvm_ruby_interpreter}-bin-${rvm_ruby_version}"
rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}"
rvm_ruby_url="${jruby_url}/${rvm_ruby_version}/${rvm_ruby_package_file}.tar.gz"
jruby_url=""
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" # Anyone else hear circus musik? ;)
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=$(
command 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}"
else
rvm_ruby_package_file="MagLev-${rvm_ruby_version}" # removed from 1.0: .${system}-${arch}
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=$(
version_tag_commit=$(
command curl -s http://github.com/api/v2/yaml/repos/show/MagLev/maglev/tags |
awk '/MagLev-'${rvm_ruby_version}':/ {print $2 }'
)
command curl -s https://raw.github.com/MagLev/maglev/$version_tag_commit/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")}"
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")${rvm_ruby_package_file}"
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 ;; # all good!
*) 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_mput_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_mput_repo_url:-"$(__rvm_db "goruby_repo_url")"}
rvm_ruby_url=$rvm_ruby_repo_url
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_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
case "${rvm_ruby_version}" in
(1.8.4)
rvm_archive_extension="tar.gz"
;;
(*)
rvm_archive_extension="tar.bz2"
;;
esac
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)) && match "$ruby_binary" "*rvm*"
then
rvm_ruby_string="$(dirname "$ruby_binary" | xargs dirname | xargs basename)"
else
rvm_ruby_interpreter="system"
fi
;;
default|system|user)
# no-op?
;;
*)
if [[ -n "${MY_RUBY_HOME:-""}" ]]
then
rvm_ruby_string=$(basename $MY_RUBY_HOME)
__rvm_select
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_ruby_string"
rvm_ruby_irbrc="$rvm_ruby_home/.irbrc"
rvm_ruby_binary="$( readlink $rvm_ruby_home/bin/ruby )"
else
rvm_ruby_package_name="${rvm_ruby_package_name:-${rvm_ruby_string//-n*}}"
rvm_ruby_home="$rvm_rubies_path/$rvm_ruby_string"
rvm_ruby_irbrc="$rvm_ruby_home/.irbrc"
rvm_ruby_binary="$rvm_ruby_home/bin/ruby"
fi
# TODO is this right place to do this ?
if [[ "maglev" == "$rvm_ruby_interpreter" ]]
then
export MAGLEV_HOME="$rvm_ruby_home"
export GEMSTONE_GLOBAL_DIR=$MAGLEV_HOME
fi
if [[ "system" != "$rvm_ruby_interpreter" ]]
then
__rvm_gemset_select
case $? in
1|3|4)
return 1
;;
esac
fi
rvm_ruby_selected_flag=1
if [[ -d "${rvm_log_path}/$rvm_ruby_string" ]]
then
\mkdir -p "${rvm_log_path}/$rvm_ruby_string"
fi
rvm_ruby_interpreter="${rvm_ruby_interpreter:-system}"
}
__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
# 'system' should *not* point to an rvm ruby.
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
# Check binaries, remove under the condition they're symlinks.
if (( ${rvm_user_install_flag:=0} == 0 ))
then
for binary in ruby gem irb ri rdoc rake erb testrb
do
full_binary_path="${rvm_bin_path}/$binary"
if [[ -L "$full_binary_path" ]]
then
\rm -f "$full_binary_path"
fi
done
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_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_scripts_path/manage" "install" "$rvm_ruby_string"
else
rvm_error "$rvm_ruby_string is not installed."
rvm_log "To install do: '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 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 # Ensure that BUNDLE_PATH is not set!
# Handle MagLev pre-installed gems
if [[ "maglev" == "$rvm_ruby_interpreter" ]]
then
GEM_PATH="$GEM_PATH:$MAGLEV_HOME/lib/maglev/gems/1.8/"
fi
[[ -n "${IRBRC:-}" ]] || unset IRBRC
# Ensure the environment file for the selected ruby exists.
__rvm_ensure_has_environment_files
if (( ${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:$MY_RUBY_HOME/bin:${rvm_bin_path}:$(__rvm_remove_rvm_from_path ;printf "%b" "$PATH")"
else
new_path="$GEM_HOME/bin:$MY_RUBY_HOME/bin:${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
# Switch the default alias to the new environment id
"$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
if [[ "maglev" == "${rvm_ruby_interpreter:-""}" ]]
then
export MAGLEV_HOME="$rvm_ruby_home"
export GEMSTONE_GLOBAL_DIR=$MAGLEV_HOME
if [[ -x "$MAGLEV_HOME/gemstone/bin/gslist" ]]
then
"$MAGLEV_HOME/gemstone/bin/gslist" -clv > /dev/null 2>&1 ; result=$?
if (( result == 1 ))
then
"$rvm_ruby_home/bin/maglev" start
fi
fi
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_ruby_string()
{
# rvm_ruby_string may designate any of the following items:
# * rvm_gemset_name
# * rvm_ruby_interpreter
# * rvm_ruby_version
# * rvm_ruby_patch_level
# * rvm_ruby_revision
# * rvm_ruby_tag
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
# Alias'd rubies
if (( rvm_expanding_aliases == 0 )) &&
[[ -n "${rvm_ruby_string}" && "$rvm_ruby_string" != "system" ]]
then
if expanded_alias_name="$("$rvm_scripts_path/alias" show "$rvm_ruby_string" 2>/dev/null)" \
&& [[ -n "$expanded_alias_name" ]]
then
rvm_ruby_string="$expanded_alias_name"
elif [[ "$rvm_ruby_string" == default ]]
then
# Default is not a known value. Instead, we need to therefore set it to system.
rvm_ruby_string="system"
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
# Stash the ruby string.
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 # <- not sold on this.
fi
strings=($(echo ${ruby_string//-/ }))
if (( ${#strings[@]} == 0 ))
then
if echo "${GEM_HOME:-}" | GREP_OPTIONS="" \grep "${rvm_path}" >/dev/null 2>&1
then
# Current Ruby
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
unset strings[__array_start]
strings=( ${strings[@]} )
strings="${strings[*]}"
rvm_ruby_name="${strings// /-}"
break
;;
(nightly)
rvm_ruby_version="nightly"
rvm_nightly_flag=1
break
;;
(preview*)
rvm_ruby_patch_level="$string"
;;
(rc[[:digit:]]*)
rvm_ruby_patch_level="$string"
;;
([[:digit:]].[[:digit:]]*)
#TODO: use normal code for rbx!
if [[ "${rvm_ruby_interpreter}" == "rbx" ]]
then
if [[ -z "${rvm_ruby_version}" ]]
then
rvm_ruby_version="${string}"
elif [[ -z "${rvm_ruby_patch_level}" ]]
then
rvm_ruby_patch_level="${string}"
else
rvm_error "Unknown ruby interpreter string component: '$string'."
return 1
fi
else
case "$string" in
(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" # Architecture
;;
(b[[:digit:]]*)
rvm_ruby_repo_branch="${string}"
rvm_head_flag=1
;;
(ruby|rbx|jruby|macruby|ree|kiji|rubinius|maglev|ironruby|goruby|tcs)
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
# Detect interpreter based on version.
case "$rvm_ruby_version" in
(1.[8-9]*) rvm_ruby_interpreter="ruby" ;;
(0.[5-6]*) rvm_ruby_interpreter="macruby" ;;
(1.[0-4]*) rvm_ruby_interpreter="rbx" ;;
(1.[5-7]*) rvm_ruby_interpreter="jruby" ;;
(2.*)
rvm_error "Version '$rvm_ruby_version' is to confusing to select ruby interpreter."
return 2
;;
esac
fi
# Unspecified version
rvm_ruby_version="${rvm_ruby_version:-}"
if [[ -z "${rvm_ruby_version:-}" && "${rvm_ruby_interpreter}" != "ext" ]] && (( ${rvm_head_flag:=0} == 0 ))
then
rvm_ruby_version="${rvm_ruby_version:-"$(
__rvm_db "${rvm_ruby_interpreter}_version"
)"}"
fi
if [[ -z "${rvm_ruby_version:-}" ]]
then
rvm_ruby_string="${rvm_ruby_interpreter}"
else
rvm_ruby_string="${rvm_ruby_interpreter}-${rvm_ruby_version}"
fi
if [[ "${rvm_ruby_interpreter}" == "ext" ]]
then
true # skip checking for external rubies
elif (( ${rvm_head_flag:=0} == 1 ))
then
rvm_ruby_string="${rvm_ruby_string}-head"
elif [[ -n "${rvm_ruby_revision:-}" ]]
then
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_revision}"
elif [[ -n "${rvm_ruby_sha:-}" ]]
then
rvm_ruby_string="${rvm_ruby_string}-s${rvm_ruby_sha}"
elif [[ -n "${rvm_ruby_tag:-}" ]]
then
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_tag}"
elif [[ -n "${rvm_ruby_patch_level:-}" ]]
then
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_patch_level}"
elif [[ -n "${rvm_ruby_user_tag:-}" ]]
then
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_user_tag}"
else
patch_level="$(
__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_patch_level"
)"
if [[ -n "${patch_level:-""}" ]]
then
case "$rvm_ruby_interpreter" in
ree|kiji|rbx)
# REE, Kiji & Rubinius use dates for their patch levels.
rvm_ruby_patch_level="${patch_level}"
;;
*)
# MRI uses -pN+ to specify the patch level.
rvm_ruby_patch_level="p${patch_level}"
;;
esac
fi
if [[ -n "${rvm_ruby_patch_level:-""}" ]]
then
rvm_ruby_patch_level="${rvm_ruby_patch_level/#pp/p}"
rvm_ruby_patch_level="${rvm_ruby_patch_level/#prc/rc}"
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_patch_level}"
case "$rvm_ruby_interpreter" in
(ree|kiji|rbx)
rvm_ruby_string="${rvm_ruby_string//-p*/-}"
;;
(*)
rvm_ruby_string="${rvm_ruby_string//-pp/-p}"
rvm_ruby_string="${rvm_ruby_string//-prc/-rc}"
;;
esac
fi
fi
if [[ -n "${rvm_ruby_name:-}" ]]
then
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_name}"
# record the name for validation of -n option
detected_rvm_ruby_name="${rvm_ruby_name}"
# clean the name so it is not added again (rbx -n install problem)
rvm_ruby_name=""
else
# record the no name for validation of -n option
detected_rvm_ruby_name=""
fi
}
__rvm_ruby_strings_exist()
{
for rvm_ruby_string in ${@//,/ }
do
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
}
#!/usr/bin/env bash
__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_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
# No longer defaulting to 'sticky' gem sets.
# Set 'rvm_sticky_flag=1' in ~/.rvmrc to enable.
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"
elif [[ -n "${GEM_HOME:-}" ]]
then
rvm_gemset_name="$GEM_HOME"
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_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
}
__rvm_gemset_select_validation()
{
# If the gemset does not exist, then notify the user as such and abort the action.
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
elif (( ${rvm_delete_flag:=0} == 1 ))
then
return 4
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
}
# Select a gemset based on CLI set options and environment.
__rvm_gemset_select_cli()
{
__rvm_gemset_select_cli_validation &&
__rvm_gemset_select
}
__rvm_gemset_select()
{
__rvm_gemset_select_only &&
__rvm_gemset_select_validation &&
__rvm_gemset_select_ensure
}
# Use a gemset specified by 'rvm_ruby_gem_home'
__rvm_gemset_use()
{
if __rvm_gemset_select_cli
then
rvm_log "Using $rvm_ruby_string with gemset ${rvm_gemset_name:-default}"
__rvm_use # Now ensure the selection takes effect for the environment.
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 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_gemset_clear()
{
export rvm_gemset_name
rvm_gemset_name=""
__rvm_use # Now ensure the selection takes effect for the environment.
}
typeset -a scripts
scripts=(
logging utility init cleanup env rvmrc install environment gemset db bundler
)
for entry in ${scripts[@]} ; do
source "$rvm_scripts_path/functions/$entry"
done
#!/usr/bin/env bash
# Logging functions
# check if user wants colors and if output goes to terminal
# rvm_pretty_print_flag:
# - 0|no - disabled always
# - 1|auto - automatic depending if the output goes to terminal (default)
# - 2|force - forced always
# to select which terminal output should be checked use first param:
# - stdout - for stdout (default)
# - stderr - for stderr
# - number - for the given terminal fd
# - else - for both stdout and stderr
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
}
case "${TERM:-dumb}" in
(dumb|unknown)
rvm_error_clr=""
rvm_warn_clr=""
rvm_debug_clr=""
rvm_notify_clr=""
rvm_reset_clr=""
;;
(*)
rvm_error_clr="$( "${rvm_scripts_path:-${rvm_pat}/scripts}/color" "${rvm_error_color:-red}" )"
rvm_warn_clr="$( "${rvm_scripts_path:-${rvm_pat}/scripts}/color" "${rvm_warn_color:-yellow}" )"
rvm_debug_clr="$( "${rvm_scripts_path:-${rvm_pat}/scripts}/color" "${rvm_debug_color:-magenta}" )"
rvm_notify_clr="$( "${rvm_scripts_path:-${rvm_pat}/scripts}/color" "${rvm_notify_color:-green}" )"
rvm_reset_clr="$( "${rvm_scripts_path:-${rvm_pat}/scripts}/color" "${rvm_reset_color:-reset}" )"
;;
esac
"${rvm_scripts_path:-${rvm_pat}/scripts}/color" "${rvm_error_color:-red}"
bash: __rvm_select: line 275: syntax error near unexpected token `('
bash: __rvm_select: line 275: ` +([[:digit:]]).+([[:digit:]]).+([[:digit:]]))'
bash: error importing function definition for `__rvm_select'
bash: __rvm_rm_rf: line 13: syntax error near unexpected token `('
bash: __rvm_rm_rf: line 13: ` *(/|.)@(|/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))'
bash: error importing function definition for `__rvm_rm_rf'
bash: __rvm_ruby_string: line 103: syntax error near unexpected token `('
bash: __rvm_ruby_string: line 103: ` 0.+([[:digit:]]) | 0.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]) | 2.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]))'
bash: error importing function definition for `__rvm_ruby_string'
bash: __rvm_parse_args: line 333: syntax error near unexpected token `('
bash: __rvm_parse_args: line 333: ` +([[:digit:]]).+([[:digit:]])*)'
bash: error importing function definition for `__rvm_parse_args'
"${rvm_scripts_path:-${rvm_pat}/scripts}/color" "${rvm_warn_color:-yellow}"
bash: __rvm_select: line 275: syntax error near unexpected token `('
bash: __rvm_select: line 275: ` +([[:digit:]]).+([[:digit:]]).+([[:digit:]]))'
bash: error importing function definition for `__rvm_select'
bash: __rvm_rm_rf: line 13: syntax error near unexpected token `('
bash: __rvm_rm_rf: line 13: ` *(/|.)@(|/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))'
bash: error importing function definition for `__rvm_rm_rf'
bash: __rvm_ruby_string: line 103: syntax error near unexpected token `('
bash: __rvm_ruby_string: line 103: ` 0.+([[:digit:]]) | 0.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]) | 2.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]))'
bash: error importing function definition for `__rvm_ruby_string'
bash: __rvm_parse_args: line 333: syntax error near unexpected token `('
bash: __rvm_parse_args: line 333: ` +([[:digit:]]).+([[:digit:]])*)'
bash: error importing function definition for `__rvm_parse_args'
"${rvm_scripts_path:-${rvm_pat}/scripts}/color" "${rvm_debug_color:-magenta}"
bash: __rvm_select: line 275: syntax error near unexpected token `('
bash: __rvm_select: line 275: ` +([[:digit:]]).+([[:digit:]]).+([[:digit:]]))'
bash: error importing function definition for `__rvm_select'
bash: __rvm_rm_rf: line 13: syntax error near unexpected token `('
bash: __rvm_rm_rf: line 13: ` *(/|.)@(|/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))'
bash: error importing function definition for `__rvm_rm_rf'
bash: __rvm_ruby_string: line 103: syntax error near unexpected token `('
bash: __rvm_ruby_string: line 103: ` 0.+([[:digit:]]) | 0.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]) | 2.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]))'
bash: error importing function definition for `__rvm_ruby_string'
bash: __rvm_parse_args: line 333: syntax error near unexpected token `('
bash: __rvm_parse_args: line 333: ` +([[:digit:]]).+([[:digit:]])*)'
bash: error importing function definition for `__rvm_parse_args'
"${rvm_scripts_path:-${rvm_pat}/scripts}/color" "${rvm_notify_color:-green}"
bash: __rvm_select: line 275: syntax error near unexpected token `('
bash: __rvm_select: line 275: ` +([[:digit:]]).+([[:digit:]]).+([[:digit:]]))'
bash: error importing function definition for `__rvm_select'
bash: __rvm_rm_rf: line 13: syntax error near unexpected token `('
bash: __rvm_rm_rf: line 13: ` *(/|.)@(|/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))'
bash: error importing function definition for `__rvm_rm_rf'
bash: __rvm_ruby_string: line 103: syntax error near unexpected token `('
bash: __rvm_ruby_string: line 103: ` 0.+([[:digit:]]) | 0.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]) | 2.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]))'
bash: error importing function definition for `__rvm_ruby_string'
bash: __rvm_parse_args: line 333: syntax error near unexpected token `('
bash: __rvm_parse_args: line 333: ` +([[:digit:]]).+([[:digit:]])*)'
bash: error importing function definition for `__rvm_parse_args'
"${rvm_scripts_path:-${rvm_pat}/scripts}/color" "${rvm_reset_color:-reset}"
bash: __rvm_select: line 275: syntax error near unexpected token `('
bash: __rvm_select: line 275: ` +([[:digit:]]).+([[:digit:]]).+([[:digit:]]))'
bash: error importing function definition for `__rvm_select'
bash: __rvm_rm_rf: line 13: syntax error near unexpected token `('
bash: __rvm_rm_rf: line 13: ` *(/|.)@(|/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))'
bash: error importing function definition for `__rvm_rm_rf'
bash: __rvm_ruby_string: line 103: syntax error near unexpected token `('
bash: __rvm_ruby_string: line 103: ` 0.+([[:digit:]]) | 0.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]) | 2.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]))'
bash: error importing function definition for `__rvm_ruby_string'
bash: __rvm_parse_args: line 333: syntax error near unexpected token `('
bash: __rvm_parse_args: line 333: ` +([[:digit:]]).+([[:digit:]])*)'
bash: error importing function definition for `__rvm_parse_args'
rvm_error()
{
if rvm_pretty_print stderr
then printf "%b" "${rvm_error_clr:-}$*${rvm_reset_clr:-}\n"
else printf "%b" "$*\n"
fi >&2
}
rvm_warn()
{
if rvm_pretty_print stdout
then printf "%b" "${rvm_warn_clr:-}$*${rvm_reset_clr:-}\n"
else printf "%b" "$*\n"
fi
}
rvm_debug()
{
if rvm_pretty_print stdout
then printf "%b" "${rvm_debug_clr:-}$*${rvm_reset_clr:-}\n"
else printf "%b" "$*\n"
fi
}
rvm_log()
{
if rvm_pretty_print stdout
then printf "%b" "${rvm_notify_clr:-}$*${rvm_reset_clr:-}\n"
else printf "%b" "$*\n"
fi
}
#!/usr/bin/env bash
if [[ -z "${rvm_tar_command:-}" ]] && builtin command -v gtar >/dev/null
then
rvm_tar_command=gtar
else
rvm_tar_command=tar
fi
if [[ ! " ${rvm_tar_options:-} " =~ " --no-same-owner " ]] && \
$rvm_tar_command --help | GREP_OPTIONS="" \grep -- --no-same-owner >/dev/null
then
rvm_tar_options="${rvm_tar_options:-} --no-same-owner"
rvm_tar_options="${rvm_tar_options## }"
fi
#
# Functions RVM is built on
#
# match <value> <string|glob>
match()
{
case "$1" in
$2) return 0 ;;
*) return 1 ;;
esac
}
printenv_null()
{
if printenv --null >/dev/null 2>/dev/null
then
printenv --null
else
# this messes with escape sequences but allows new lines in variables
printenv | sed '/=/ { s/=.*$//; p; }; d;' | while read name
do
zero="\0"
eval "eval \"printf '%b' '$name=\$$name$zero'\""
done
fi
}
is_a_function() {
typeset -f $1 >/dev/null 2>&1 || return $?
}
#
# RVM specific functions.
#
__rvm_warn_on_rubyopt()
{
if [[ -n "${RUBYOPT:-""}" ]]; then
rvm_warn \
"Please note: You have the RUBYOPT environment variable set and this \
may interfere with normal rvm operations. We sugges unsetting it."
return 1
else
return 0
fi
}
__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
}
# Return a list of directories under a given base path.
# Derived from rvm_ruby_string.
__rvm_ruby_string_paths_under()
{
typeset path part parts
path="${1%/}" # Strip off any trailing slash
parts=(${rvm_ruby_string//-/ }) # Strip white space.
echo "$path"
for part in "${parts[@]}"
do
path="$path/$part"
echo "$path"
done
return 0
}
# Run a specified command and log it.
__rvm_run()
{
typeset name log temp_log_path _command message
true ${rvm_debug_flag:=0} ${rvm_niceness:=0}
name="${1:-}"
_command="${2:-}"
message="${3:-}"
if [[ -n "$message" ]]
then
rvm_log "$message"
fi
if (( rvm_debug_flag > 0 ))
then
rvm_debug "Executing: $_command"
fi
if [[ -n "${rvm_ruby_string:-}" ]]
then
temp_log_path="${rvm_log_path}/$rvm_ruby_string"
else
temp_log_path="${rvm_log_path}"
fi
log="$temp_log_path/$name.log"
if [[ ! -d "${log%\/*}" ]]
then
\mkdir -p "${log%\/*}"
fi
if [[ ! -f "$log" ]]
then
\touch "$log" # for zsh :(
fi
# TODO: Allow an 'append_flag' setting?
printf "%b" "[$(date +'%Y-%m-%d %H:%M:%S')] $_command\n" > "$log"
if (( rvm_niceness > 0 ))
then
_command="nice -n $rvm_niceness $_command"
fi
eval "$_command" >> "$log" 2>&1
result=$?
if (( result > 0 ))
then
rvm_error "Error running '$_command', please read $log"
fi
return ${result}
}
# Output the current ruby's rvm source path.
__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
}
# Output an inspection of selected 'binary' scripts, based on CLI selection.
__rvm_inspect()
{
for binary in $rvm_ruby_args
do
actual_file="$(unset -f gem ; builtin command -v gem )"
rvm_log "$actual_file:"
if [[ ${rvm_shebang_flag:-0} -eq 1 ]]
then
\head -n 1 < "$actual_file"
fi
if [[ ${rvm_env_flag:-0} -eq 1 ]]
then
\awk '/ENV/' < "$actual_file"
fi
if [[ ${rvm_path_flag:-0} -eq 1 ]]
then
\awk '/PATH/' < "$actual_file"
fi
if [[ ${rvm_head_flag:-0} -eq 1 ]]
then
\head -n 5 < "$actual_file"
fi
if [[ ${rvm_tail_flag:-0} -eq 1 ]]
then
\tail -n 5 < "$actual_file"
fi
if [[ ${rvm_all_flag:-0} -eq 1 ]]
then
\cat $actual_file
fi
done
return 0
}
# Strip whitespace and normalize it all.
__rvm_strip()
{
\sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]\{1,\}/ /g'
return $?
}
__rvm_remove_from_path()
{
export PATH
PATH=":$PATH:"
PATH="${PATH//:$1:/:}"
PATH="${PATH//::/:}"
PATH="${PATH%:}"
PATH="${PATH#:}"
}
__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" ;;
#*) anything else will just remove it from PATH - not adding back
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
}
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
}
rvm_is_a_shell_function()
{
if (( ${rvm_is_not_a_shell_function:-0} > 0 )) && [[ "${1:-}" != "no_warning" ]]
then
if rvm_pretty_print stderr
then
printf "%b" "\n${rvm_notify_clr:-}RVM is not a function, selecting rubies with '${rvm_error_clr:-}rvm use ...${rvm_notify_clr:-}' will not work.${rvm_reset_clr:-}\n" >&2
else
printf "%b" "\nRVM is not a function, selecting rubies with 'rvm use ...' will not work.\n" >&2
fi
if is_parent_of gnome-terminal $$ >/dev/null
then
rvm_log "Please visit https://rvm.io/integration/gnome-terminal/ for a solution.\n" >&2
else
rvm_log "You need to change your terminal settings to allow shell login.
Please visit https://rvm.io/workflow/screen/ for example.\n" >&2
fi
fi
return ${rvm_is_not_a_shell_function:-0}
}
__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;}'
fi
}
__rvm_detect_xcode_version_is()
{
[[ "$(__rvm_detect_xcode_version)" == "$1" ]] || return 1
}
__rvm_version_compare()
{
typeset v1d v2d dots counter IFS
typeset -a transformer
counter=1
IFS="+" # to put + in transformer ;)
v1d=$( printf -- $1 | GREP_OPTIONS="" \grep -o '\.' | wc -l )
v2d=$( printf -- $3 | GREP_OPTIONS="" \grep -o '\.' | wc -l )
if [[ $v1d -ge $v2d ]]
then dots=$v1d
else dots=$v2d
fi
while (( dots >= 0 ))
do transformer+=( "$(( 256 ** dots-- ))*\$$((counter++))" )
done
eval "$(
printf '[[ ';
printf $1 | \awk -F. "{ printf ${transformer[*]} }";
printf -- " $2 ";
printf $3 | \awk -F. "{ printf ${transformer[*]} }";
printf ' ]]'
)"
}
__function_on_stack()
{
typeset fun
for fun in "$@"
do
if [[ " ${FUNCNAME[*]} " =~ " $fun " ]]
then return 0
fi
done
return $#
}
__rvm_pager_or_cat_v()
{
eval "${PAGER:-cat -v} '$1'"
}
#!/usr/bin/env bash
__rvm_load_rvmrc()
{
typeset _file
if (( ${rvm_ignore_rvmrc:=0} == 1 ))
then
return 0
fi
: rvm_stored_umask:${rvm_stored_umask:=$(umask)}
for _file in /etc/rvmrc "$HOME/.rvmrc"
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
}
# Initialize rvm, ensuring that the path and directories are as expected.
__rvm_initialize()
{
export rvm_ruby_load_path rvm_ruby_require
rvm_ruby_load_path="."
rvm_ruby_require=""
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
}
#!/usr/bin/env bash
#
# rm -rf with *some* safeguards in place.
#
__rvm_rm_rf()
{
typeset result target
result=1
target="${1%%+(/|.)}"
#NOTE: RVM Requires extended globbing shell feature turned on.
if [[ -n "${ZSH_VERSION:-}" ]]
then
setopt extendedglob
else
if [[ -n "${BASH_VERSION:-}" ]]
then
shopt -s extglob # Extended globs
else
printf "%b" "What the heck kind of shell are you running here???\n"
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))
false
;;
(*)
if [[ -n "${target}" ]]
then
if [[ -d "${target}" ]]
then # Directory
\rm -rf "${target}"
result=0
elif [[ -f "${target}" || -L "${target}" ]]
then # File / Symbolic Link
\rm -f "${target}"
result=0
else
result=0 # already gone!?
fi
fi
;;
esac
return $result
}
__rvm_reboot()
{
rvm_warn "Do you wish to reboot rvm?\n('yes', or 'no')> "
typeset response
response="no"
read response
if [[ "yes" == "$response" ]]
then
builtin 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
}
# Cleans up temp folders for a given prefix ($1),
# or the current process id.
__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
}
#!/usr/bin/env bash
#
# Environment manipulation functions.
#
__rvm_default_flags()
{
true ${rvm_head_flag:=0} ${rvm_delete_flag:=0}
}
__rvm_nuke_rvm_variables()
{
unset rvm_head_flag $(env | awk -F= '/^rvm_/{print $1" "}')
}
# Unset ruby-specific variables
__rvm_unset_ruby_variables()
{
# unset rvm_ruby_flag $(env | awk -F= '/^rvm_ruby_/{printf $1" "}')
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_ruby_load_path rvm_ruby_require 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 # restore important variables
}
# TODO: Should be able to...
# Unset both rvm variables as well as ruby-specific variables
# Preserve gemset if 'rvm_sticky' is set
# (persist gemset unless clear is explicitely called).
__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_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_make_flags 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_configure_flags 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_ruby_aliases rvm_patch_names rvm_install_args rvm_dump_environment_flag rvm_ruby_alias rvm_static_flag rvm_archive_extension rvm_hook rvm_ruby_name
# rvm_gemsets_path rvm_user_path rvm_wrappers_path rvm_patches_path rvm_docs_path rvm_examples_path rvm_rubies_path rvm_usr_path rvm_src_path rvm_tmp_path rvm_lib_path rvm_repos_path rvm_log_path rvm_help_path rvm_environments_path rvm_archives_path
__rvm_load_rvmrc # restore important variables
}
# Add bin path if not present
__rvm_conditionally_add_bin_path()
{
if printf "%b" "${PATH//:/ }" | GREP_OPTIONS="" \grep -vF "${rvm_bin_path}" >/dev/null 2>&1
then
case "${rvm_ruby_string:-"system"}" in
system)
PATH="$PATH:${rvm_bin_path}"
;;
*)
PATH="${rvm_bin_path}:$PATH"
;;
esac
builtin hash -r
fi
return 0
}
__rvm_load_environment()
{
typeset string
string="$1"
if [[ -f "$rvm_environments_path/$string" ]]; then
# Restore the path to it's state minus rvm
__rvm_remove_rvm_from_path
# source the environment file
\. "$rvm_environments_path/$string"
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
then
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
fi
# clear the PATH cache
builtin hash -r
elif [[ -n "$string" ]] ; then
rvm "$string"
else
: # TODO: This should have some error handling in the context.
fi
return 0
}
__rvm_export()
{
# extract the variable name from the first arg.
typeset name
name=${1%%=*}
# store the current value, to be restored later.
builtin export rvm_old_$name=${!name}
# pass-through the return value of the builtin.
export "$@"
return $?
}
__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)
}
# Clean all *duplicate* items out of the path. (keep first occurrence of each)
__rvm_clean_path()
{
PATH="$(printf "%b" "$PATH" \
| awk -v RS=: -v ORS=: '!($0 in a){a[$0];print}')"
PATH="${PATH/%:/}" # Strip trailing : if it exists
export PATH
builtin hash -r
}
# Clean all rvm items out of the current working path.
__rvm_remove_rvm_from_path()
{
PATH="$(printf "%b" "$PATH" \
| awk -v RS=: -v ORS=: "/${rvm_path//\//\/}/ {next} {print}")"
PATH="${PATH/%:/}" # Strip trailing : if it exists
export PATH
builtin hash -r
}
#!/usr/bin/env bash
export escape_flag _first _second
escape_flag=1
_first=${__array_start}
_second=$[__array_start + 1]
__rvm_md5_for()
{
if builtin command -v md5 > /dev/null; then
echo "$1" | md5
elif builtin command -v md5sum > /dev/null ; then
echo "$1" | md5sum | awk '{print $1}'
else
rvm_error "Neither md5 nor md5sum were found in the PATH"
return 1
fi
return 0
}
__rvm_sha256_for()
{
if builtin command -v sha256sum > /dev/null ; then
echo "$1" | sha256sum | awk '{print $1}'
elif builtin command -v sha256 > /dev/null ; then
echo "$1" | sha256 | awk '{print $1}'
elif builtin command -v shasum > /dev/null ; then
echo "$1" | shasum -a256 | awk '{print $1}'
else
rvm_error "Neither sha256sum nor shasum found in the PATH"
return 1
fi
return 0
}
__rvm_md5_for_contents()
{
if builtin command -v md5 > /dev/null
then
echo "$1" | cat - "$1" | md5
elif builtin command -v md5sum > /dev/null
then
echo "$1" | cat - "$1" | md5sum | awk '{print $1}'
else
rvm_error "Neither md5 nor md5sum were found in the PATH"
return 1
fi
return 0
}
__rvm_sha256_for_contents()
{
if builtin command -v sha256sum > /dev/null ; then
echo "$1" | cat - "$1" | sha256sum | awk '{print $1}'
elif builtin command -v sha256 > /dev/null ; then
echo "$1" | cat - "$1" | sha256 | awk '{print $1}'
elif builtin command -v shasum > /dev/null ; then
echo "$1" | cat - "$1" | shasum -a256 | awk '{print $1}'
else
rvm_error "Neither sha256sum nor shasum found in the PATH"
return 1
fi
return 0
}
__rvm_rvmrc_key()
{
printf "%b" "$1" | \tr '[#/.=]' _
return $?
}
__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_trust_rvmrc()
{
__rvm_reset_rvmrc_trust "$1"
"$rvm_scripts_path/db" "$rvm_user_path/rvmrcs" \
"$(__rvm_rvmrc_key "$1")" "1;$(__rvm_md5_for_contents "$1")$(__rvm_sha256_for_contents "$1")" >/dev/null 2>&1
return $?
}
__rvm_untrust_rvmrc()
{
__rvm_reset_rvmrc_trust "$1"
"${rvm_scripts_path:-"$rvm_path/scripts"}/db" "$rvm_user_path/rvmrcs" \
"$(__rvm_rvmrc_key "$1")" "0;$(__rvm_md5_for_contents "$1")$(__rvm_sha256_for_contents "$1")" >/dev/null 2>&1
}
__rvm_rvmrc_stored_trust()
{
"${rvm_scripts_path:-"$rvm_path/scripts"}/db" "$rvm_user_path/rvmrcs" \
"$(__rvm_rvmrc_key "$1")"
return $?
}
__rvm_rvmrc_tools()
{
export escape_flag
typeset rvmrc_action rvmrc_path saveIFS trust rvmrc_ruby
escape_flag=1
rvmrc_action="$1"
(( $# )) && shift || true
if [[ "${rvmrc_action}" == "create" ]]
then
rvmrc_ruby="${1:-${MY_RUBY_HOME##*/}}"
rvmrc_path="$(builtin cd "$PWD" >/dev/null 2>&1; pwd)"
elif [[ "${1:-}" == "all" ]]
then
rvmrc_path="all"
else
rvmrc_path="$(builtin cd "${1:-$PWD}" >/dev/null 2>&1; pwd)"
fi
(( $# )) && shift || true
if (( $# ))
then rvmrc_path="${rvmrc_path}/$1"
elif [[ -s "${rvmrc_path}/.rvmrc" ]]
then rvmrc_path="${rvmrc_path}/.rvmrc"
elif [[ -s "${rvmrc_path}/.versions.conf" ]]
then rvmrc_path="${rvmrc_path}/.versions.conf"
elif [[ -f "${rvmrc_path}/.ruby-version" ]]
then rvmrc_path="${rvmrc_path}/.ruby-version"
elif [[ -f "${rvmrc_path}/.rbfu-version" ]]
then rvmrc_path="${rvmrc_path}/.rbfu-version"
elif [[ -f "${rvmrc_path}/.rbenv-version" ]]
then rvmrc_path="${rvmrc_path}/.rbenv-version"
elif [[ -f "${rvmrc_path}/Gemfile" ]]
then rvmrc_path="${rvmrc_path}/Gemfile"
elif [[ "${rvmrc_path}" == "all" ]]
then rvmrc_path="all"
else rvmrc_path="${rvmrc_path}/.rvmrc"
fi
case "$rvmrc_action" in
create)
(
rvm_ruby_string="${rvmrc_ruby}"
rvm_create_flag=1 __rvm_use
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"
echo "Reset trust for $rvmrc_path"
;;
trust)
__rvm_trust_rvmrc "$rvmrc_path"
echo "Marked $rvmrc_path as trusted"
;;
untrust)
__rvm_untrust_rvmrc "$rvmrc_path"
echo "Marked $rvmrc_path as untrusted"
;;
trusted)
if [[ -f "$rvmrc_path" ]]
then
saveIFS=$IFS
IFS=$';'
trust=($(__rvm_rvmrc_stored_trust "$rvmrc_path"))
IFS=$saveIFS
if [[ "${trust[${_second}]:-'#'}" != "$(__rvm_md5_for_contents "$rvmrc_path")$(__rvm_sha256_for_contents "$rvmrc_path")" ]]
then
echo "The rvmrc at '$rvmrc_path' contains unreviewed changes."
elif [[ "${trust[${_first}]}" == '1' ]]
then
echo "The rvmrc at '$rvmrc_path' is currently trusted."
elif [[ "${trust[${_first}]}" == '0' ]]
then
echo "The rvmrc at '$rvmrc_path' is currently untrusted."
else
echo "The trustiworthiness of '$rvmrc_path' is currently unknown."
fi
else
echo "There is no $rvmrc_path"
fi
;;
is_trusted)
if [[ -f "$rvmrc_path" ]]
then
saveIFS=$IFS
IFS=$';'
trust=($(__rvm_rvmrc_stored_trust "$rvmrc_path"))
IFS=$saveIFS
if [[ "${trust[${_second}]:-'#'}" != "$(__rvm_md5_for_contents "$rvmrc_path")$(__rvm_sha256_for_contents "$rvmrc_path")" ]]
then
return 1
elif [[ "${trust[${_first}]}" == '1' ]]
then
return 0
else
return 1
fi
else
return 1
fi
;;
load)
rvm_rvmrc_cwd="" rvm_trust_rvmrcs_flag=1 \
__rvm_project_rvmrc "$(dirname "$rvmrc_path")" "$(basename "$rvmrc_path")"
;;
try_to_read_ruby)
case "$rvmrc_path" in
(*/.rvmrc)
if ! __rvm_rvmrc_tools is_trusted "$(dirname "$rvmrc_path")" "$(basename "$rvmrc_path")"
then
# subprocess to not mess with current process variables
( __rvm_project_rvmrc "$(dirname "$rvmrc_path")" "$(basename "$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_rvmrc_cwd=""
rvm_trust_rvmrcs_flag=1
__rvm_project_rvmrc "$(dirname "$rvmrc_path")" "$(basename "$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_rvmrc_cwd=""
rvm_trust_rvmrcs_flag=1
__rvm_project_rvmrc "$(dirname "$rvmrc_path")" "$(basename "$rvmrc_path")" >/dev/null 2>&1
__rvm_env_string
)"
rvm_ruby_strings="$rvm_ruby_string"
;;
esac
;;
*)
echo "Usage: rvm rvmrc {trust,untrust,trusted,load,reset,is_trusted,try_to_read_ruby}"
return 1
;;
esac
unset escape_flag
return $?
}
__rvm_check_rvmrc_trustworthiness()
{
typeset saveIFS trust result
# Trust when they have the flag... of doom!
if [[ -n "$1" && ${rvm_trust_rvmrcs_flag:-0} == 0 ]]
then
saveIFS="$IFS"
IFS=$';'
trust=( $( __rvm_rvmrc_stored_trust "$1" ) )
IFS="$saveIFS"
if [[ "${trust[${_second}]:-'#'}" != "$(__rvm_md5_for_contents "$1")$(__rvm_sha256_for_contents "$1")" ]]
then
__rvm_ask_to_trust "$1"
else
[[ "${trust[${_first}]}" == '1' ]]
fi
fi
result=$?
unset escape_flag
return $result
}
__rvm_display_rvmrc()
{
typeset _rvmrc_base _read_char_flag
_rvmrc_base="$(basename "${_rvmrc}")"
[[ -n "${ZSH_VERSION:-}" ]] && _read_char_flag=k || _read_char_flag=n
printf "
====================================================================================
= %-80s =
= 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. =
= =
= %-80s =
= changes, and may change the trust setting manually at any time. =
====================================================================================
(( press a key to review the ${_rvmrc_base} file ))
" \
"The contents of the ${_rvmrc_base} file will now be displayed." \
"Note: You will be re-prompted each time the ${_rvmrc_base} file's contents change"
builtin read -${_read_char_flag} 1 -s -r anykey
printf "%b" "${rvm_warn_clr}"
command cat -v "${_rvmrc}"
printf "%b" "${rvm_reset_clr}"
printf "
====================================================================================
= %-80s =
====================================================================================
= %-80s =
= %-80s =
= 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. =
====================================================================================
" \
"Viewing of ${_rvmrc} complete." \
"Trusting an ${_rvmrc_base} file means that whenever you cd into this directory," \
"RVM will run this ${_rvmrc_base} shell script."
}
__rvm_ask_to_trust()
{
typeset trusted value anykey _rvmrc
_rvmrc="${1}"
if [[ ! -t 0 ]] || (( ${rvm_promptless:=0} == 1 )) || [[ -n "$MC_SID" ]]
then
return 2
fi
printf "====================================================================================
= NOTICE =
====================================================================================
= %-80s =
= 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! ( Choose v[iew] below to view the contents ) =
====================================================================================
" \
"RVM has encountered a new or modified $(basename "${_rvmrc}") file in the current directory"
trusted=0
while (( ! trusted ))
do
printf "Do you wish to trust this $(basename "${_rvmrc}") file? (%b)\n" "${_rvmrc}"
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
}
# Checks the rvmrc for the given directory. Note that if
# argument is passed, it will be used instead of pwd.
__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 # no nesting
fi
typeset working_dir requested_file found_file rvm_trustworthiness_result
# Get the first argument or the pwd.
working_dir="${1:-"$PWD"}"
requested_file="${2:-}"
while :
do
if [[ -z "$working_dir" || "$HOME" == "$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"
elif [[ -n "${rvm_previous_environment:-""}" ]]
then
__rvm_load_environment "$rvm_previous_environment"
fi
unset rvm_current_rvmrc rvm_previous_environment
fi
break
else
if [[ -n "${requested_file}" && -f "$working_dir/${requested_file}" ]]
then found_file="$working_dir/${requested_file}"
elif [[ -f "$working_dir/.rvmrc" ]]
then found_file="$working_dir/.rvmrc"
elif [[ -f "$working_dir/.versions.conf" ]]
then found_file="$working_dir/.versions.conf"
elif [[ -f "$working_dir/.ruby-version" ]]
then found_file="$working_dir/.ruby-version"
elif [[ -f "$working_dir/.rbfu-version" ]]
then found_file="$working_dir/.rbfu-version"
elif [[ -f "$working_dir/.rbenv-version" ]]
then found_file="$working_dir/.rbenv-version"
elif [[ -f "$working_dir/Gemfile" ]]
then found_file="$working_dir/Gemfile"
fi
if [[ -n "${found_file}" ]]
then
if [[ "${rvm_current_rvmrc:-""}" != "${found_file}" ]]
then
if __rvm_conditionally_do_with_env __rvm_load_project_config "${found_file}"
then true
else
rvm_trustworthiness_result=$?
unset __rvm_project_rvmrc_lock
return "$rvm_trustworthiness_result"
fi
fi
break
else
working_dir="$(dirname "$working_dir")"
fi
fi
done
unset __rvm_project_rvmrc_lock
return $?
}
__rvm_load_project_config()
{
typeset __gemfile
: rvm_autoinstall_bundler_flag:${rvm_autoinstall_bundler_flag:=0}
case "$1" in
(*/.rvmrc)
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
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="$(sed -n '/^ruby=/ {s/ruby=//;p;}' < "$1")"
[[ -n "${rvm_ruby_string}" ]] || return 2
rvm_gemset_name="$(sed -n '/^ruby-gemset=/ {s/ruby-gemset=//;p;}' < "$1")"
rvm_create_flag=1 __rvm_use || return 3
# TODO: read env.* # how to sanitize ?
_gem_names="$(sed -n '/^ruby-gem-install=/ {s/ruby-gem-install=//;p;}' < "$1")"
for _gem in ${_gem_names//,/ }
do
# TODO: add support for versions
if ! gem list | GREP_OPTIONS="" \grep "^${_gem} " > /dev/null
then gem install "${_gem}"
fi
done
_bundle_install="$(sed -n '/^ruby-bundle-install=/ {s/ruby-bundle-install=//;p;}' < "$1")"
if [[ -n "${_bundle_install}" ]] || [[ "${rvm_autoinstall_bundler_flag:-0}" == 1 ]]
then
if [[ "${_bundle_install}" == true ]] # prevent file named true for Gemfile
then __gemfile="$(dirname $1)/Gemfile"
elif [[ -f "${_bundle_install}" ]]
then __gemfile="${_bundle_install}"
elif [[ "${rvm_autoinstall_bundler_flag:-0}" == 1 ]]
then __gemfile="$(dirname $1)/Gemfile"
fi
fi
;;
(*/Gemfile)
typeset _bundler_version
__rvm_ensure_is_a_function
rvm_previous_environment="$(__rvm_env_string)"
rvm_current_rvmrc="$1"
rvm_ruby_string="$(sed -n '/^#ruby=/ {s/#ruby=//;p;}' < "$1")"
[[ -n "${rvm_ruby_string}" ]] || return 2
rvm_gemset_name="$(sed -n '/^#ruby-gemset=/ {s/#ruby-gemset=//;p;}' < "$1")"
rvm_create_flag=1 __rvm_use || return 3
# TODO: read #env.* # how to sanitize ?
if [[ "${rvm_autoinstall_bundler_flag:-0}" == "1" ]]
then
_bundler_version="$(sed -n '/^#ruby-bundler-version=/ {s/#ruby-bundler-version=//;p;}' < "$1")"
if ! gem list | GREP_OPTIONS="" \grep "^bundler " | \grep "${_bundler_version}" > /dev/null
then
[[ -z "${_bundler_version}" ]] || _bundler_version=" -v ${_bundler_version}"
gem install "bundler${_bundler_version}"
fi
__gemfile="$1"
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="$(cat "$1")"
[[ -n "${rvm_ruby_string}" ]] || return 2
if [[ -f "$(dirname $1)/.ruby-gemset" ]]
then
rvm_gemset_name="$(cat "$(dirname $1)/.ruby-gemset")"
fi
rvm_create_flag=1 __rvm_use || return 3
# "$(dirname $1)/.rbenv-vars" ... can we support those without licensing ?
if [[ "${rvm_autoinstall_bundler_flag:-0}" == 1 && -f "$(dirname $1)/Gemfile" ]]
then
_bundler_version="$(sed -n '/^#ruby-bundler-version=/ {s/#ruby-bundler-version=//;p;}' < "$1")".strip
if ! gem list | GREP_OPTIONS="" \grep "^bundler " | \grep "${_bundler_version}" > /dev/null
then
[[ -z "${_bundler_version}" ]] || _bundler_version=" -v ${_bundler_version}"
gem install "bundler${_bundler_version}"
fi
__gemfile="$(dirname $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_project_rvmrc_with_env()
{
__rvm_do_with_env __rvm_project_rvmrc "$@"
}
__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_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
echo "$(__rvm_env_string)" >> .ruby-version
}
__rvm_set_rvmrc()
{
typeset flags identifier short_identifier gem_file
true ${rvm_verbose_flag:=0}
if [[ "$HOME" != "$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