scripts/selector in rvm-1.0.1 vs scripts/selector in rvm-1.0.2
- old
+ new
@@ -35,11 +35,11 @@
rvm_url="$rvm_url/$rvm_ruby_package_name"
fi
unset rvm_ruby_patch_level
else
- $rvm_scripts_path/log "fail" "MacRuby can only be installed on a Darwin OS."
+ "$rvm_scripts_path/log" "fail" "MacRuby can only be installed on a Darwin OS."
fi
;;
rbx|rubinius)
rvm_archive_extension="tar.gz"
@@ -129,12 +129,12 @@
rvm_ruby_package_file="ruby-enterprise-$rvm_ruby_version-$rvm_ruby_patch_level"
rvm_url="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_url")/$rvm_ruby_package_file.tar.gz"
fi
fi
- if ! $rvm_scripts_path/match "$rvm_ruby_version" "^1\.8" ; then
- $rvm_scripts_path/log "fail" "Unknown Ruby Enterprise Edition version: $rvm_ruby_version"
+ if ! "$rvm_scripts_path/match" "$rvm_ruby_version" "^1\.8" ; then
+ "$rvm_scripts_path/log" "fail" "Unknown Ruby Enterprise Edition version: $rvm_ruby_version"
fi
;;
mput|shyouhei)
rvm_ruby_interpreter="mput"
@@ -146,22 +146,22 @@
unset rvm_ruby_configure rvm_ruby_make rvm_ruby_make_install
;;
ruby)
if [[ -z "$rvm_ruby_version" && -z "$rvm_head_flag" ]]; then
- $rvm_scripts_path/log "fail" "Unknown ruby version: $rvm_ruby_version"
+ "$rvm_scripts_path/log" "fail" "Unknown ruby version: $rvm_ruby_version"
else
rvm_ruby_repo_url="${rvm_ruby_repo_url:-"$(__rvm_db "ruby_repo_url")"}"
if [[ -z "$rvm_head_flag" ]]; then
rvm_archive_extension="tar.bz2"
fi
fi
;;
current)
ruby_binary="$(command -v ruby)"
- if [[ $? -eq 0 ]] && $rvm_scripts_path/match "$ruby_binary" "rvm" ; then
+ if [[ $? -eq 0 ]] && "$rvm_scripts_path/match" "$ruby_binary" "rvm" ; then
rvm_ruby_string="$(dirname "$ruby_binary" | xargs dirname | xargs basename)"
else
rvm_ruby_interpreter="system"
fi
;;
@@ -174,23 +174,23 @@
if [[ ! -z "$MY_RUBY_HOME" ]] ; then
rvm_ruby_string=$(basename $MY_RUBY_HOME)
__rvm_select
else
if [[ -z "$rvm_ruby_string" ]] ; then
- $rvm_scripts_path/log "fail" "Ruby implementation '$rvm_ruby_interpreter' is not known."
+ "$rvm_scripts_path/log" "fail" "Ruby implementation '$rvm_ruby_interpreter' is not known."
return 1
fi
fi
esac
__rvm_gemset_select
if [[ -n "$rvm_ruby_interpreter" && "system" != "$rvm_ruby_interpreter" && "default" != "$rvm_ruby_interpreter" ]] ; then
if [[ ! -z "$rvm_ruby_version" ]] ; then
- rvm_release_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $1 }')
- rvm_major_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $2 }')
- rvm_minor_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $3 }')
+ rvm_release_version="${rvm_ruby_version/.*/}"
+ rvm_major_version=${rvm_ruby_version%.*} ; rvm_major_version=${rvm_major_version#*.}
+ rvm_minor_version="${rvm_ruby_version//*.}"
fi
rvm_ruby_package_name="${rvm_ruby_package_name:-$(echo $rvm_ruby_string | sed -e 's/-n.*$//')}"
rvm_ruby_home="$rvm_rubies_path/$rvm_ruby_string"
rvm_ruby_log_path="$rvm_log_path/$rvm_ruby_string"
@@ -247,11 +247,11 @@
[[ -L "$full_binary_path" ]] && \rm -f "$full_binary_path"
done; unset binary full_binary_path
fi
if [[ ! -z "$rvm_verbose_flag" ]] ; then
- $rvm_scripts_path/log "info" "Now using system ruby."
+ "$rvm_scripts_path/log" "info" "Now using system ruby."
fi
export rvm_ruby_string="system"
else
@@ -265,24 +265,24 @@
export GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION IRBRC
if [[ -z "$IRBRC" ]] ; then unset IRBRC ; fi
if [[ ! -d $MY_RUBY_HOME ]] ; then
- $rvm_scripts_path/log "warn" "$rvm_ruby_interpreter $rvm_ruby_string is not installed."
+ "$rvm_scripts_path/log" "warn" "$rvm_ruby_interpreter $rvm_ruby_string is not installed."
if [[ ! -z "$rvm_install_on_use_flag" ]] ; then
- $rvm_scripts_path/manage "install" "$rvm_ruby_string"
+ "$rvm_scripts_path/manage" "install" "$rvm_ruby_string"
else
- $rvm_scripts_path/log "info" "To install do: 'rvm install $rvm_ruby_string'"
+ "$rvm_scripts_path/log" "info" "To install do: 'rvm install $rvm_ruby_string'"
return 1
fi
fi
# Ensure the environment file for the selected ruby exists.
__rvm_ensure_has_environment_files
if [[ ! -z "$rvm_verbose_flag" ]] ; then
- $rvm_scripts_path/log "info" "Using $(basename $GEM_HOME | \tr '-' ' ' | sed 's/'${rvm_gemset_separator}'/ with gemset /')"
+ "$rvm_scripts_path/log" "info" "Using $(basename $GEM_HOME | \tr '-' ' ' | sed 's/'${rvm_gemset_separator}'/ with gemset /')"
fi
new_path="$GEM_HOME/bin:$rvm_ruby_global_gems_path/bin:$MY_RUBY_HOME/bin:$rvm_bin_path:$(__rvm_remove_rvm_from_path ; printf $PATH)"
fi
@@ -299,53 +299,53 @@
environment_id="$(__rvm_environment_identifier)"
if [[ -n "$rvm_default_flag" && "default" != "$rvm_ruby_interpreter" ]] ; then
if [[ "$rvm_selfcontained" = "0" ]] ; then
# Sets up the default wrappers.
- $rvm_scripts_path/wrapper "$rvm_ruby_string" --no-prefix
+ "$rvm_scripts_path/wrapper" "$rvm_ruby_string" --no-prefix
else
- $rvm_scripts_path/wrapper "$rvm_scripts_path" "default"
+ "$rvm_scripts_path/wrapper" "$rvm_scripts_path" "default"
fi
if [[ "system" = "$rvm_ruby_interpreter" ]] ; then
- $rvm_scripts_path/alias delete default &> /dev/null
+ "$rvm_scripts_path/alias" delete default &> /dev/null
\find "$rvm_bin_path" -name 'default_*' -maxdepth 1 -delete
- \rm -f $rvm_config_path/default
- \rm -f $rvm_environments_path/default
- \rm -rf $rvm_wrappers_path/default
+ \rm -f "$rvm_config_path/default"
+ \rm -f "$rvm_environments_path/default"
+ \rm -rf "$rvm_wrappers_path/default"
else
- RUBY_VERSION="$($rvm_ruby_home/bin/ruby -v | sed 's#^\(.*\) (.*$#\1#')"
+ RUBY_VERSION="$("$rvm_ruby_home/bin/ruby" -v | sed 's#^\(.*\) (.*$#\1#')"
export GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION
- $rvm_scripts_path/alias delete default &> /dev/null
- $rvm_scripts_path/alias create default "$environment_id" >& /dev/null
- ln -nfs $rvm_environments_path/$environment_id $rvm_environments_path/default
- ln -nfs $rvm_wrappers_path/$environment_id $rvm_wrappers_path/default
+ "$rvm_scripts_path/alias" delete default &> /dev/null
+ "$rvm_scripts_path/alias" create default "$environment_id" >& /dev/null
+ ln -nfs "$rvm_environments_path/$environment_id" "$rvm_environments_path/default"
+ ln -nfs "$rvm_wrappers_path/$environment_id" "$rvm_wrappers_path/default"
fi
fi ; unset rvm_default_flag
if [[ -n "$rvm_wrapper_name" ]] ; then
- $rvm_scripts_path/wrapper "$environment_id" "$rvm_wrapper_name" > /dev/null 2>&1
+ "$rvm_scripts_path/wrapper" "$environment_id" "$rvm_wrapper_name" > /dev/null 2>&1
unset rvm_wrapper_name
fi
if [[ -n "$rvm_ruby_alias" ]]; then
- $rvm_scripts_path/log "info" "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
+ "$rvm_scripts_path/log" "info" "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
unset ruby_alias rvm_ruby_alias
fi
unset environment_id
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 -eq 1 ]] ; then $rvm_ruby_home/bin/maglev start ; fi
+ "$MAGLEV_HOME/gemstone/bin/gslist" -clv > /dev/null 2>&1 ; result=$?
+ if [[ $result -eq 1 ]] ; then "$rvm_ruby_home/bin/maglev" start ; fi
fi
fi
- rvm_hook="after_use" ; source $rvm_scripts_path/hook
+ rvm_hook="after_use" ; source "$rvm_scripts_path/hook"
}
__rvm_ruby_string() {
# rvm_ruby_string may designate any of the following items:
# * rvm_gemset_name
@@ -353,10 +353,17 @@
# * rvm_ruby_version
# * rvm_ruby_patch_level
# * rvm_ruby_revision
# * rvm_ruby_tag
+ if printf "$rvm_ruby_string" | \grep -q "$rvm_gemset_separator" ; then
+ set_name="${rvm_ruby_string/*${rvm_gemset_separator}/}"
+ else
+ set_name=""
+ fi
+ if [[ -n "$set_name" ]] ; then rvm_gemset_name="$set_name" ; fi
+
# Alias'd rubies
if [[ -z "$rvm_expanding_aliases" ]]; then
rvm_ruby_string="${rvm_ruby_string:-"default"}"
expanded_alias_name="$($rvm_scripts_path/alias show "$rvm_ruby_string" 2>/dev/null)"
if [[ -n "$expanded_alias_name" ]]; then
@@ -364,18 +371,15 @@
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
+ ruby_string=${rvm_ruby_string/${rvm_gemset_separator}*/}
- set_name=$(echo "$rvm_ruby_string" | awk -F${rvm_gemset_separator} '{print $2}')
- if [[ ! -z "$set_name" ]] ; then rvm_gemset_name="$set_name" ; fi
- ruby_string=$(echo "$rvm_ruby_string" | awk -F${rvm_gemset_separator} '{print $1}')
-
__rvm_unset_ruby_variables
- for string in $(echo $ruby_string | \tr '-' ' ') ; do
+ for string in $(printf "${ruby_string//-/ }") ; do
if [[ "head" = "$string" ]] ; then
rvm_ruby_revision="head"
unset rvm_ruby_patch_level rvm_ruby_revision rvm_ruby_tag
export rvm_head_flag=1
elif [[ "system" = "$string" ]] ; then
@@ -384,20 +388,20 @@
return
elif [[ "nightly" = "$string" ]] ; then
rvm_ruby_version="nightly"
rvm_nightly_flag=1
break
- elif $rvm_scripts_path/match "$string" "^preview" ; then
+ elif "$rvm_scripts_path/match" "$string" "^preview" ; then
rvm_ruby_patch_level="$string"
- elif $rvm_scripts_path/match "$string" "^rc[0-9]" ; then
+ elif "$rvm_scripts_path/match" "$string" "^rc[0-9]" ; then
rvm_ruby_patch_level="$string"
- elif $rvm_scripts_path/match "$string" "^[0-9]\.[0-9]" ; then
+ elif "$rvm_scripts_path/match" "$string" "^[0-9]\.[0-9]" ; then
rvm_ruby_version="$string"
unset rvm_ruby_revision rvm_ruby_tag
- elif $rvm_scripts_path/match "$string" "^p[0-9]" ; then
+ elif "$rvm_scripts_path/match" "$string" "^p[0-9]" ; then
rvm_ruby_patch_level="$string"
- elif [[ -n "$rvm_ruby_version" ]] && $rvm_scripts_path/match "$string" "^[0-9][0-9]" ; then
+ elif [[ -n "$rvm_ruby_version" ]] && "$rvm_scripts_path/match" "$string" "^[0-9][0-9]" ; then
if [[ "ree" = "$rvm_ruby_interpreter" ]] ; then
rvm_ruby_patch_level="$string"
unset rvm_ruby_revision
elif [[ "rbx" = "$rvm_ruby_interpreter" ]] ; then
rvm_ruby_patch_level="$string"
@@ -405,44 +409,44 @@
rvm_ruby_version="$string"
unset rvm_ruby_revision rvm_ruby_patch_level
else
rvm_ruby_revision="r$string"
fi
- elif $rvm_scripts_path/match "$string" "^r[0-9]" ; then
+ elif "$rvm_scripts_path/match" "$string" "^r[0-9]" ; then
unset rvm_ruby_patch_level
rvm_ruby_revision="$string"
- elif $rvm_scripts_path/match "$string" "^s[0-9]" ; then
+ elif "$rvm_scripts_path/match" "$string" "^s[0-9]" ; then
unset rvm_ruby_revision
rvm_ruby_sha="$string"
- elif $rvm_scripts_path/match "$string" "^t[v0-9]" ; then
+ elif "$rvm_scripts_path/match" "$string" "^t[v0-9]" ; then
unset rvm_ruby_patch_level rvm_ruby_revision
rvm_ruby_tag="$string"
- elif $rvm_scripts_path/match "$string" "^m[0-9]" ; then
+ elif "$rvm_scripts_path/match" "$string" "^m[0-9]" ; then
rvm_ruby_mode="$string"
- elif $rvm_scripts_path/match "$string" "^u[a-z0-9]" ; then
+ elif "$rvm_scripts_path/match" "$string" "^u[a-z0-9]" ; then
unset rvm_ruby_patch_level rvm_ruby_revision rvm_ruby_tag rvm_ruby_patch
rvm_ruby_user_tag="$string"
- elif $rvm_scripts_path/match "$string" "^b[0-9][0-9]" ; then
+ elif "$rvm_scripts_path/match" "$string" "^b[0-9][0-9]" ; then
rvm_ruby_bits="$string"
- elif $rvm_scripts_path/match "$string" "^n" ; then
+ elif "$rvm_scripts_path/match" "$string" "^n" ; then
rvm_ruby_name="${string/n/}"
- elif $rvm_scripts_path/match "ruby rbx jruby macruby ree rubinius maglev mput shyouhei ironruby " "$string " ; then
+ elif [[ "ruby rbx jruby macruby ree rubinius maglev mput shyouhei ironruby " =~ "$string " ]] ; then
# NOTE: The space at the end of each of the above strings is *very* important.
rvm_ruby_interpreter="$string"
else
- $rvm_scripts_path/log "error" "Unknown ruby string component: '$string'"
+ "$rvm_scripts_path/log" "error" "Unknown ruby string component: '$string'"
return 1
fi
done
# Unspecified interpreter
if [[ -z "$rvm_ruby_interpreter" ]] ; then
- if $rvm_scripts_path/match "$rvm_ruby_version" "^1\.[8-9]" ; then
+ if "$rvm_scripts_path/match" "$rvm_ruby_version" "^1\.[8-9]" ; then
rvm_ruby_interpreter="ruby"
- elif $rvm_scripts_path/match "$rvm_ruby_version" "^0.5" ; then
+ elif "$rvm_scripts_path/match" "$rvm_ruby_version" "^0.5" ; then
rvm_ruby_interpreter="macruby"
- elif $rvm_scripts_path/match "$rvm_ruby_version" "^1.[2-4]" ; then
+ elif "$rvm_scripts_path/match" "$rvm_ruby_version" "^1.[2-4]" ; then
rvm_ruby_interpreter="jruby"
fi
fi
# Unspecified version
@@ -511,11 +515,11 @@
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 [[ -n "$rvm_gemset_name" ]] && ! $rvm_scripts_path/match "$rvm_gemset_name" "^[0-9]\.[0-9]" ; then
+ if [[ -n "$rvm_gemset_name" ]] && ! "$rvm_scripts_path/match" "$rvm_gemset_name" "^[0-9]\.[0-9]" ; then
rvm_ruby_gem_home="$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator}${rvm_gemset_name}"
else
if [[ -n "$rvm_ruby_string" ]] && [[ "$rvm_ruby_interpreter" != "system" ]] ; then
rvm_ruby_gem_home="$rvm_gems_path/$rvm_ruby_string"
elif [[ -z "$GEM_HOME" ]] && [[ -n "$(command -v gem)" ]] ; then
@@ -538,19 +542,19 @@
rvm_ruby_gem_home="$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator}${rvm_gemset_name}"
elif [[ -n "$gemset" ]] && [[ "$rvm_gemset_name" != "$gemset" ]] ; then
rvm_ruby_gem_home="$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator}${rvm_gemset_name}"
fi ; unset gemset
else
- $rvm_scripts_path/log "error" "Gemsets can not be used with non rvm controlled rubies (currently)."
+ "$rvm_scripts_path/log" "error" "Gemsets can not be used with non rvm controlled rubies (currently)."
return 1
fi
fi
# If the gemset does not exist, then notify the user as such and abort the action.
if [[ -n "$rvm_gemset_name" ]] && [[ ! -d "$rvm_ruby_gem_home" ]] ; then
if [[ "$rvm_gemset_create_on_use_flag" -ne 1 ]] && [[ "$rvm_create_flag" -ne 1 ]] && [[ "$rvm_delete_flag" -ne 1 ]] ; then
- $rvm_scripts_path/log "error" "Gemset '$rvm_gemset_name' does not exist, rvm gemset create '$rvm_gemset_name' first."
+ "$rvm_scripts_path/log" "error" "Gemset '$rvm_gemset_name' does not exist, rvm gemset create '$rvm_gemset_name' first."
return 1
fi
elif [[ "$rvm_delete_flag" -eq 1 ]] ; then
return 1
fi
@@ -578,35 +582,35 @@
# Use a gemset specified by 'rvm_ruby_gem_home'
__rvm_gemset_use() {
if [[ -n "$rvm_ruby_gem_home" ]] ; then
if [[ ! -d "$rvm_ruby_gem_home" ]] ; then
if [[ "$rvm_gemset_create_on_use_flag" -eq 1 ]] || [[ "$rvm_create_flag" -eq 1 ]]; then
- $rvm_scripts_path/gemsets create $rvm_gemset_name
+ "$rvm_scripts_path/gemsets" create "$rvm_gemset_name"
else
- $rvm_scripts_path/log "error" "Gemset '$rvm_gemset_name' does not exist, rvm gemset create '$rvm_gemset_name' first."
+ "$rvm_scripts_path/log" "error" "Gemset '$rvm_gemset_name' does not exist, rvm gemset create '$rvm_gemset_name' first."
return 1
fi
fi
if [[ "$rvm_interactive" -eq 1 ]] || [[ "$rvm_verbose_flag" -eq 1 ]] ; then
- $rvm_scripts_path/log "info" "Now using gemset '${rvm_gemset_name:-default}'"
+ "$rvm_scripts_path/log" "info" "Now using gemset '${rvm_gemset_name:-default}'"
fi
- rvm_ruby_gem_home="$(echo $GEM_HOME | sed 's/'${rvm_gemset_separator}'.*$//')${rvm_gemset_separator}${rvm_gemset_name}"
+ rvm_ruby_gem_home="$(echo "$GEM_HOME" | sed 's/'${rvm_gemset_separator}'.*$//')${rvm_gemset_separator}${rvm_gemset_name}"
GEM_HOME="$rvm_ruby_gem_home"
BUNDLE_PATH="$rvm_ruby_gem_home"
- GEM_PATH="$rvm_ruby_gem_home/bin:$(echo $GEM_HOME | sed 's/'${rvm_gemset_separator}'.*$//')${rvm_gemset_separator}global/bin"
+ GEM_PATH="$rvm_ruby_gem_home/bin:$(echo "$GEM_HOME" | sed 's/'${rvm_gemset_separator}'.*$//')${rvm_gemset_separator}global/bin"
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() {
unset rvm_gemset_name ; shift
- rvm_ruby_gem_home="$(echo $GEM_HOME | sed "s#${rvm_gemset_separator:-'@'}.*\$##g")"
- rvm_ruby_global_gems_path="$(echo $GEM_HOME | sed 's/'${rvm_gemset_separator}'.*$//')${rvm_gemset_separator}global"
+ rvm_ruby_gem_home="$(echo "$GEM_HOME" | sed "s#${rvm_gemset_separator:-'@'}.*\$##g")"
+ rvm_ruby_global_gems_path="$(echo "$GEM_HOME" | sed 's/'${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/bin:$rvm_ruby_global_gems_path/bin"
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.