scripts/selector in rvm-1.0.11 vs scripts/selector in rvm-1.0.13
- old
+ new
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
# __rvm_select implementation version patch_level
-__rvm_select() {
-
+__rvm_select()
+{
# Set Variable Defaults
export GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION
if [[ -z "${rvm_ruby_string:-""}" ]] ; then
[[ -n "${rvm_ruby_interpreter:-""}" ]] && rvm_ruby_string="$rvm_ruby_interpreter"
@@ -231,11 +231,11 @@
export GEMSTONE_GLOBAL_DIR=$MAGLEV_HOME
fi
rvm_ruby_gem_home="${rvm_gems_path:-"$rvm_path/gems"}/${rvm_ruby_string}"
- if [[ ! -z "$rvm_gemset_name" ]] ; then
+ if [[ -n "$rvm_gemset_name" ]] ; then
rvm_ruby_gem_home="${rvm_ruby_gem_home}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
rvm_ruby_gem_path="${rvm_ruby_gem_home}:${rvm_gems_path:-"$rvm_path/gems"}/${rvm_ruby_string}${rvm_gemset_separator:-"@"}global"
fi
rvm_ruby_global_gems_path="${rvm_ruby_gem_home%%${rvm_gemset_separator:-"@"}*}${rvm_gemset_separator:-"@"}global"
@@ -252,11 +252,12 @@
else
rvm_ruby_interpreter="${rvm_ruby_interpreter:-system}"
fi
}
-__rvm_use() {
+__rvm_use()
+{
local new_path binary full_binary_path rvm_ruby_gem_home
#if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select "$@" ; fi
__rvm_select "$@"
@@ -264,11 +265,11 @@
if [[ "system" = "$rvm_ruby_interpreter" ]] ; then
unset GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION IRBRC
- new_path="${rvm_bin_path:-"$rvm_path/bin"}:$(__rvm_remove_rvm_from_path ; printf "$PATH")"
+ new_path="$(__rvm_remove_rvm_from_path ; printf "$PATH"):${rvm_bin_path:-"$rvm_path/bin"}"
if [[ -s $rvm_path/config/system ]] ; then
\grep "MY_RUBY_HOME='$rvm_path/rubies" "$rvm_path/config/system" > /dev/null
@@ -336,13 +337,17 @@
new_path="$GEM_HOME/bin:$rvm_ruby_global_gems_path/bin:$MY_RUBY_HOME/bin:${rvm_bin_path:-"$rvm_path/bin"}:$(__rvm_remove_rvm_from_path ; printf "$PATH")"
fi
# Export ruby string and gem set me for extrenal scripts to take advantage of them.
- if [[ -n "${rvm_ruby_string:-""}" ]] ; then export rvm_ruby_string ; fi
+ if [[ -n "${rvm_ruby_string:-""}" ]] ; then
+ export rvm_ruby_string
+ fi
- if [[ -n "${rvm_gemset_name:-""}" ]] ; then export rvm_gemset_name ; fi
+ if [[ -n "${rvm_gemset_name:-""}" ]] ; then
+ export rvm_gemset_name
+ fi
if [[ -n "$new_path" ]]; then
export PATH="$new_path"
unset new_path
builtin hash -r
@@ -407,11 +412,12 @@
rvm_hook="after_use" ; source "$rvm_path/scripts/hook"
return 0
}
-__rvm_ruby_string() {
+__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
@@ -435,11 +441,11 @@
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 -q "${rvm_gemset_separator:-"@"}" ; then
rvm_gemset_name="${rvm_ruby_string/*${rvm_gemset_separator:-"@"}/}"
rvm_ruby_string="${rvm_ruby_string/${rvm_gemset_separator:-"@"}*/}"
rvm_sticky_flag=1
fi
@@ -646,18 +652,17 @@
fi
}
# Select a gemset based on CLI set options and environment.
# This only sets 'rvm_ruby_gem_home'
-__rvm_gemset_select() {
-
+__rvm_gemset_select()
+{
command -v gem > /dev/null
if [[ $? -gt 0 ]] ; then return 0 ; fi # Stop if no 'gem' command is available.
rvm_ruby_gem_home=${rvm_ruby_gem_home:-""}
rvm_gemset_name=${rvm_gemset_name:-""}
- rvm_ruby_global_gems_path="${rvm_ruby_gem_home%%${rvm_gemset_separator:-"@"}*}${rvm_gemset_separator:-"@"}global"
if [[ -z "${rvm_gemset_name:-""}" ]] ; then
# No longer defaulting to 'sticky' gem sets.
# Set 'rvm_sticky_flag=1' in ~/.rvmrc to enable.
@@ -670,11 +675,12 @@
if [[ -n "${rvm_ruby_gem_home:-""}" ]] ; then
rvm_gemset_name=$(echo $rvm_ruby_gem_home | xargs basename | awk -F${rvm_gemset_separator:-"@"} '{print $2}')
fi
fi
- if ! echo "${rvm_gemset_name:-""}" | grep -q "^[[:digit:]]\.[[:digit:]]" ; then
+ if [[ -n "${rvm_gemset_name:-""}" ]] &&
+ ! echo "${rvm_gemset_name:-""}" | grep -q "^[[:digit:]]\.[[:digit:]]" ; then
rvm_ruby_gem_home="${rvm_gems_path:-"$rvm_path/gems"}/${rvm_ruby_string}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
else
if [[ -n "${rvm_ruby_string:-""}" && "${rvm_ruby_interpreter:-""}" != "system" ]] ; then
@@ -727,13 +733,13 @@
return 1
fi
if [[ -z "${rvm_ruby_gem_home:-""}" && -n "${rvm_ruby_string:-""}" ]] ; then
rvm_ruby_gem_home="${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string"
- rvm_ruby_global_gems_path="${rvm_ruby_gem_home%%${rvm_gemset_separator}*}${rvm_gemset_separator:-"@"}global"
fi
+ rvm_ruby_global_gems_path="${rvm_ruby_gem_home%%${rvm_gemset_separator:-"@"}*}${rvm_gemset_separator:-"@"}global"
rvm_ruby_gem_path="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"
# Ensure that the ruby gem home exists.
\mkdir -p "$rvm_ruby_gem_home"
if [[ -n "${rvm_ruby_gem_home:-""}" ]] && echo "$rvm_ruby_gem_home" | \grep -q 'rvm'; then
@@ -746,50 +752,66 @@
export rvm_ruby_gem_path rvm_ruby_gem_home
}
# Use a gemset specified by 'rvm_ruby_gem_home'
-__rvm_gemset_use() {
+__rvm_gemset_use()
+{
if [[ -z "${rvm_gemset_name:-""}" ]] ; then
- "$rvm_path/scripts/log" "error" "Gemset was not given.\n Usage:\n rvm gemset use <gemsetname>\n"
+ "$rvm_path/scripts/log" "error" \
+ "Gemset was not given.\n Usage:\n rvm gemset use <gemsetname>\n"
return 1
fi
if [[ -n "${rvm_ruby_gem_home:-""}" ]] ; then
if [[ ! -d "$rvm_ruby_gem_home" ]] ; then
- if [[ ${rvm_gemset_create_on_use_flag:-0} -eq 1 || ${rvm_create_flag:-0} -eq 1 ]] ; then
+ if [[ ${rvm_gemset_create_on_use_flag:-0} -eq 1 \
+ || ${rvm_create_flag:-0} -eq 1 ]] ; then
"$rvm_path/scripts/gemsets" create "$rvm_gemset_name"
else
- "$rvm_path/scripts/log" "error" "Gemset '$rvm_gemset_name' does not exist, rvm gemset create '$rvm_gemset_name' first."
+ "$rvm_path/scripts/log" "error" \
+ "Gemset '$rvm_gemset_name' does not exist, rvm gemset create '$rvm_gemset_name' first."
return 1
fi
fi
if [[ ${rvm_interactive_flag:-0} -gt 0 && ${rvm_verbose_flag:-1} -ne 0 ]] ; then
"$rvm_path/scripts/log" "info" "Now using gemset '${rvm_gemset_name:-default}'"
fi
rvm_ruby_gem_home="${GEM_HOME//${rvm_gemset_separator:-"@"}*}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
+ rvm_ruby_global_gems_path="${rvm_ruby_gem_home%%${rvm_gemset_separator:-"@"}*}${rvm_gemset_separator:-"@"}global"
+
GEM_HOME="$rvm_ruby_gem_home"
BUNDLE_PATH="$rvm_ruby_gem_home"
GEM_PATH="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"
+
export rvm_ruby_gem_home GEM_HOME BUNDLE_PATH GEM_PATH
__rvm_use # Now ensure the selection takes effect for the environment.
fi
return 0
}
-__rvm_gemset_clear() {
- rvm_gemset_name="" ; shift # TODO: Is this shift necessary???
+__rvm_gemset_clear()
+{
+ rvm_gemset_name=""
+
rvm_ruby_gem_home="${GEM_HOME//${rvm_gemset_separator:-"@"}*}"
- rvm_ruby_global_gems_path="${rvm_ruby_gem_home%%${rvm_gemset_separator:-"@"}*}${rvm_gemset_separator:-"@"}global"
+
+ rvm_ruby_global_gems_path="${rvm_ruby_gem_home}${rvm_gemset_separator:-"@"}global"
+
GEM_HOME=$rvm_ruby_gem_home
+
BUNDLE_PATH="$rvm_ruby_gem_home"
+
GEM_PATH="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"
+
export rvm_ruby_gem_home rvm_ruby_global_gems_path GEM_HOME BUNDLE_PATH GEM_PATH
+
__rvm_use # Now ensure the selection takes effect for the environment.
+
}