scripts/cli in rvm-0.1.20 vs scripts/cli in rvm-0.1.21

- old
+ new

@@ -48,34 +48,58 @@ if $rvm_scripts_path/match "$1" "^[0-9]\.[0-9]" ; then rvm_ruby_version=$1 ; shift ; fi ;; gemset) rvm_action=$rvm_token + + export rvm_ruby_gem_home="$GEM_HOME" + if [[ "clear" = "$1" ]] ; then unset rvm_gemset_name ; shift - export rvm_ruby_gem_home="$(echo $GEM_HOME | sed 's/%.*$//')" - export GEM_HOME="$rvm_ruby_gem_home" - export BUNDLE_PATH="$rvm_ruby_gem_home" - export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_gem_home%global/bin" rvm_ruby_args="clear" - rvm_parse_break=1 - elif [[ "delete" = "$1" ]] || [[ "use" = "$1" ]] ; then - export rvm_${1}_flag=1 - export rvm_ruby_args="$@" ; shift + elif [[ "use" = "$1" ]] ; then + rvm_use_flag=1 + rvm_ruby_args="$@" ; shift + export rvm_use_flag rvm_ruby_args rvm_gemset_name="$1"; shift - export rvm_ruby_string=$(echo $rvm_gemset_name | sed 's/\(.*\)%.*/\1/') - export rvm_gemset_name=$(echo $rvm_gemset_name | sed 's/.*%\(.*\)/\1/') - if [[ "$rvm_ruby_string" != "$rvm_gemset_name" ]] ; then export rvm_ruby_string ; fi + if [[ ! -z "$(echo $rvm_gemset_name | grep '%')" ]] ; then + rvm_ruby_string=$(echo $rvm_gemset_name | sed 's/\(.*\)%.*/\1/') + rvm_gemset_name=$(echo $rvm_gemset_name | sed 's/.*%\(.*\)/\1/') + if [[ "$rvm_ruby_string" != "$rvm_gemset_name" ]] ; then + export rvm_ruby_string="$rvm_ruby_string%$rvm_gemset_name" + else + unset rvm_ruby_string + fi + export rvm_ruby_gem_home="$rvm_ruby_gem_home%$rvm_gemset_name" + fi if [[ ! -z "$rvm_gemset_name" ]] ; then export rvm_gemset_name ; fi + elif [[ "delete" = "$1" ]] ; then + rvm_delete_flag=1 + rvm_ruby_args="$@" ; shift + rvm_gemset_name="$1"; shift + export rvm_delete_flag rvm_ruby_args rvm_gemset_name + if [[ ! -z "$(echo $rvm_gemset_name | grep '%')" ]] ; then + rvm_ruby_string=$(echo $rvm_gemset_name | sed 's/\(.*\)%.*/\1/') + rvm_gemset_name=$(echo $rvm_gemset_name | sed 's/.*%\(.*\)/\1/') + if [[ "$rvm_ruby_string" != "$rvm_gemset_name" ]] ; then + export rvm_ruby_string="$rvm_ruby_string%$rvm_gemset_name" + else + unset rvm_ruby_string + fi + export rvm_ruby_gem_home="$rvm_ruby_gem_home%$rvm_gemset_name" + fi + if [[ ! -z "$rvm_gemset_name" ]] ; then export rvm_gemset_name ; fi else if [[ -z "$1" ]] ; then rvm_action="error" - rvm_error_message="'gems' must be followed by a gemset action, see http://rvm.beginrescueend.com/gemsets/ for details." + rvm_error_message="'gemset' must be followed by a gemset action, see http://rvm.beginrescueend.com/gemsets/ for details." else - export rvm_ruby_args="$*" ; export rvm_${1}_flag=1 ; shift + if [[ "$rvm_ruby_string" != "$rvm_gemset_name" ]] ; then export rvm_ruby_string ; else unset rvm_ruby_string ; fi + rvm_ruby_args="$@" ; export rvm_ruby_args fi fi + rvm_parse_break=1 ;; gemdir) rvm_action=$rvm_token rvm_gemdir_flag=1 @@ -276,11 +300,10 @@ --make) rvm_ruby_make="$1" ; shift ;; --make-install) rvm_ruby_make_install="$1" ; shift ;; --nice) rvm_niceness="$1" ; shift ;; -l|--level) rvm_ruby_patch_level="p$1" ; shift ;; # TODO: handle this below better (if $1 is null) - -m|--gemset) rvm_gemset_name="$1" ; shift ;; --sdk) rvm_sdk="$1" ; shift ;; --archflags) rvm_archflags="$1" ; shift ;; --symlink) rvm_symlink_name="$1" ; shift ;; --install) export rvm_install_on_use_flag=1 ;; --trace) export rvm_trace_flag=1 ; set -x ;; @@ -406,17 +429,29 @@ ruby|gem|rake) $rvm_scripts_path/set $rvm_action $rvm_ruby_args result=$? ;; gemset) + #if $rvm_scripts_path/match $rvm_ruby_args use ; then if [[ "$rvm_use_flag" -eq 1 ]] ; then __rvm_gemset_select - result=$? - if [[ $result -eq 0 ]] ; then + result=$? ; if [[ $result -eq 0 ]] ; then __rvm_gemset_use fi else $rvm_scripts_path/gemsets $rvm_ruby_args + + # Clear the gemset. + if [[ "$rvm_delete_flag" -eq 1 ]] ; then + gem_prefix="$(echo $GEM_HOME | sed 's/%.*$//')" + if [[ "$GEM_HOME" = "$gem_prefix%$rvm_gemset_name" ]] ; then + rvm_ruby_gem_home="$gem_prefix" + GEM_HOME="$rvm_ruby_gem_home" + BUNDLE_PATH="$rvm_ruby_gem_home" + GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_gem_home%global/bin" + export rvm_ruby_gem_home GEM_HOME BUNDLE_PATH GEM_PATH + fi ; unset gem_prefix + fi fi result=$? ;; monitor)