scripts/cli in rvm-1.0.2 vs scripts/cli in rvm-1.0.3
- old
+ new
@@ -14,30 +14,39 @@
# Otherwise this file gets big rather fast.
#echo "$@" >> $HOME/.rvm_history
if echo "$@" | \grep -q 'trace' ; then echo "$@" ; __rvm_version ; fi
+ rvm_action="${rvm_action:-""}"
+ export rvm_ruby_string="${rvm_ruby_string:-""}"
+
+ local rvm_parse_break=0
+ local rvm_error_message=""
+
while [[ $# -gt 0 ]] ; do
- rvm_token="$1" ; shift
+ rvm_token="$next_token" ; shift
+
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; else next_token="" ; fi
+
case "$rvm_token" in
fetch|version|srcdir|reset|debug|reload|update|monitor|notes|implode|seppuku|question|answer|env)
rvm_action=$rvm_token
;;
package)
rvm_action="$rvm_token"
- if [[ "$1" = "--only-path" ]]; then
+ if [[ "$next_token" = "--only-path" ]]; then
shift; rvm_only_path_flag=1
fi
- rvm_ruby_args="$@"
+ rvm_ruby_args="$*"
rvm_parse_break=1
;;
use)
rvm_action="$rvm_token"
rvm_verbose_flag=1
- if [[ "ruby" = "$1" ]] ; then shift ; fi
+ if [[ "ruby" = "$next_token" ]] ; then shift ; fi
;;
install|uninstall)
export ${rvm_token}_flag=1
rvm_action=$rvm_token
@@ -54,60 +63,63 @@
if [[ "rubinius" = "$rvm_token" ]] ; then rvm_token="rbx"; fi
rvm_ruby_interpreter="$rvm_token"
rvm_ruby_string="$rvm_token"
rvm_ruby_strings="$rvm_token"
rvm_action="${rvm_action:-use}"
- if "$rvm_scripts_path"/match "$1" "^[0-9]\.[0-9]" ; then rvm_ruby_version=$1 ; shift ; fi
+ if "$rvm_scripts_path"/match "$next_token" "^[0-9]\.[0-9]" ; then rvm_ruby_version=$next_token ; shift ; fi
;;
gemset)
rvm_action=$rvm_token
rvm_ruby_gem_home="$GEM_HOME"
- if [[ "clear" = "$1" ]] ; then
+ if [[ -z "$next_token" ]] ; then
+ rvm_ruby_args="help"
+ elif [[ "clear" = "$next_token" ]] ; then
__rvm_gemset_clear
rvm_ruby_args="clear"
- elif [[ "use" = "$1" ]] ; then
+ elif [[ "use" = "$next_token" ]] ; then
rvm_use_flag=1
rvm_ruby_args="$@" ; shift
- rvm_gemset_name="$1" ; shift
+ rvm_gemset_name="$next_token" ; shift
if [[ ! -z "$(echo $rvm_gemset_name | \grep $rvm_gemset_separator)" ]] ; then
rvm_ruby_string=$(echo $rvm_gemset_name | sed 's/\(.*\)'${rvm_gemset_separator}'.*/\1/')
rvm_gemset_name=$(echo $rvm_gemset_name | sed 's/.*'${rvm_gemset_separator}'\(.*\)/\1/')
if [[ "$rvm_ruby_string" != "$rvm_gemset_name" ]] ; then
rvm_ruby_string="$rvm_ruby_string${rvm_gemset_separator}$rvm_gemset_name"
fi
rvm_ruby_gem_home="$rvm_ruby_gem_home${rvm_gemset_separator}$rvm_gemset_name"
fi
- elif [[ "delete" = "$1" ]] ; then
+ elif [[ "delete" = "$next_token" ]] ; then
rvm_delete_flag=1
rvm_ruby_args="$@" ; shift
- rvm_gemset_name="$1"; shift
+ rvm_gemset_name="$next_token"; shift
if echo "$rvm_gemset_name" | \grep -q "$rvm_gemset_separator" ; then
rvm_ruby_string=$(echo "$rvm_gemset_name" | sed 's/\(.*\)'${rvm_gemset_separator}'.*/\1/')
rvm_gemset_name=$(echo "$rvm_gemset_name" | sed 's/.*'${rvm_gemset_separator}'\(.*\)/\1/')
if [[ "$rvm_ruby_string" != "$rvm_gemset_name" ]] ; then
rvm_ruby_string="$rvm_ruby_string${rvm_gemset_separator}$rvm_gemset_name"
fi
rvm_ruby_gem_home="$rvm_ruby_gem_home${rvm_gemset_separator}$rvm_gemset_name"
fi
else
+ rvm_gemset_name="${rvm_gemset_name:-""}"
if [[ "$rvm_ruby_string" != "$rvm_gemset_name" ]] ; then __rvm_ruby_string ; fi
rvm_ruby_args="$@"
fi
rvm_parse_break=1
;;
gemdir|gempath|gemhome)
rvm_action=$rvm_token
rvm_gemdir_flag=1
- if [[ "system" = "$1" ]] ; then rvm_system_flag=1 ; shift ; fi
- if [[ "user" = "$1" ]] ; then rvm_user_flag=1 ; shift ; fi
+ if [[ "system" = "$next_token" ]] ; then rvm_system_flag=1 ; shift ; fi
+ if [[ "user" = "$next_token" ]] ; then rvm_user_flag=1 ; shift ; fi
;;
- inspect|list|info)
+ inspect|list|info|strings)
rvm_action="$rvm_token"
rvm_ruby_args="$@"
rvm_parse_break=1
;;
@@ -140,49 +152,49 @@
rvm_ruby_args="$(__rvm_quote_args "$@")"
rvm_parse_break=1
;;
do|ruby|rake|gem|rubydo|rakedo|gemdo)
- if [[ "do" = "$rvm_action" ]] ; then rvm_action="ruby" ; fi
+ if [[ "do" = "${rvm_action:-""}" ]] ; then rvm_action="ruby" ; fi
rvm_action=$(echo $rvm_token | sed 's#do##g')
- if [[ "rake" = "$rvm_action" ]] || [[ "gem" = "$rvm_action" ]] || [[ "ruby" = "$rvm_action" ]] ; then
- if [[ -z "$1" ]] ; then
- if [[ "gem" = "$rvm_action" ]] ; then
+ if [[ "rake" = "${rvm_action:-""}" || "gem" = "${rvm_action:-""}" || "ruby" = "${rvm_action:-""}" ]] ; then
+ if [[ -z "$next_token" ]] ; then
+ if [[ "gem" = "${rvm_action:-""}" ]] ; then
rvm_action="error"
rvm_error_message="'rvm $rvm_action' must be followed by arguments."
- elif [[ "ruby" = "$rvm_action" ]] ; then
- if echo "$rvm_ruby_strings" | \grep -q ',' ; then
+ elif [[ "ruby" = "${rvm_action:-""}" ]] ; then
+ if echo "$rvm_ruby_strings":-""} | \grep -q ',' ; then
rvm_action="ruby"
rvm_ruby_args=""
else
rvm_action="error"
rvm_error_message="rvm X,Y,Z '$rvm_action' must be followed by arguments."
fi
fi
- elif [[ "-S" = "$1" ]] ; then
+ elif [[ "-S" = "$next_token" ]] ; then
rvm_action="ruby"
rvm_ruby_args="$flag $(__rvm_quote_args "$@")"
rvm_parse_break=1
- elif [[ "-e" = "$1" ]] ; then
+ elif [[ "-e" = "$next_token" ]] ; then
rvm_action="ruby"
rvm_ruby_args="$flag $(__rvm_quote_args "$@")"
rvm_parse_break=1
else
rvm_ruby_args="$(__rvm_quote_args "$@")"
rvm_parse_break=1
fi
else
- if "$rvm_scripts_path"/match "$1" "^-" ; then
+ if "$rvm_scripts_path"/match "$next_token" "^-" ; then
unset rvm_ruby_strings
else
- if "$rvm_scripts_path"/match "$1" "^[0-9]" ; then
+ if "$rvm_scripts_path"/match "$next_token" "^[0-9]" ; then
rvm_ruby_strings="${1//,/ }" ; shift
unset rvm_ruby_interpreter
else
- if [[ "ruby rbx jruby macruby ree rubinius maglev mput shyouhei ironruby" =~ $1 ]] ; then
- rvm_ruby_strings=$1
- rvm_ruby_interpreter=$1
+ if [[ "ruby rbx jruby macruby ree rubinius maglev mput shyouhei ironruby" =~ $next_token ]] ; then
+ rvm_ruby_strings=$next_token
+ rvm_ruby_interpreter=$next_token
shift
else
unset rvm_ruby_interpreter rvm_ruby_strings
fi
fi
@@ -198,52 +210,52 @@
rvm_action="rake"
rvm_ruby_args="$(echo $rvm_token | sed -e 's/s$//')"
;;
-v|--version)
- if [[ -z "$1" ]] ; then
+ if [[ -z "$next_token" ]] ; then
rvm_action="version"
else
- rvm_ruby_version="$1"
+ rvm_ruby_version="$next_token"
shift
fi
;;
--repository|--repo|--url)
rvm_ruby_repo_url=$rvm_token
;;
--ree-options)
- if [[ ! -z "$1" ]] ; then
+ if [[ ! -z "$next_token" ]] ; then
export rvm_ree_options="${1//,/ }" ; shift
else
rvm_action="error"
rvm_error_message="--ree-options *must* be followed by... well... options."
fi
;;
--patches|--patch)
- rvm_patch_names="$1 $rvm_patch_names"; shift
+ rvm_patch_names="$next_token ${rvm_patch_names:-""}"; shift
rvm_patch_original_pwd="$PWD"
;;
--head) rvm_head_flag=1 ;;
--bin)
- if [[ "update" = "$rvm_action" ]] ; then
+ if [[ "update" = "${rvm_action:-""}" ]] ; then
rvm_bin_flag=1
else
- rvm_bin_path="$1" ; shift
+ rvm_bin_path="$next_token" ; shift
fi
;;
-r|--require)
- if [[ -z "$1" ]] ; then
+ if [[ -z "$next_token" ]] ; then
rvm_action="error"
rvm_error_message="-r|--require *must* be followed by a library name."
else
- rvm_ruby_require="$rvm_ruby_require -r$1"
+ rvm_ruby_require="$rvm_ruby_require -r$next_token"
shift
fi
;;
--rdoc|--yard)
@@ -251,11 +263,11 @@
rvm_docs_type
;;
-f|--file)
rvm_action="ruby"
- rvm_ruby_file="$1"
+ rvm_ruby_file="$next_token"
shift
;;
system|default)
rvm_action=${rvm_action:-use}
@@ -273,11 +285,11 @@
--passenger|--editor)
rvm_wrapper_name="${rvm_token/--/}"
;;
--alias)
- if [[ -n "$1" ]]; then
+ if [[ -n "$next_token" ]]; then
rvm_ruby_aliases="$(echo "${rvm_ruby_aliases//,/ } ${1//,/ }" | __rvm_strip)"
shift
fi
;;
@@ -286,71 +298,89 @@
shift
;;
wrapper)
rvm_action="$rvm_token"
- rvm_ruby_string="$1" ;
- [[ -n "$1" ]] && shift
- rvm_wrapper_name="$1"
- [[ -n "$1" ]] && shift
+ rvm_ruby_string="$next_token" ;
+ [[ -n "$next_token" ]] && shift
+ rvm_wrapper_name="$next_token"
+ [[ -n "$next_token" ]] && shift
rvm_ruby_args="$@" # list of binaries, or none
rvm_parse_break=1
;;
- -G) path_variable="rvm_gems_path" ; __rvm_set_path_variable "$1"; shift ;;
- --source) path_variable="rvm_src_path" ; __rvm_set_path_variable "$1"; shift ;;
- --archives) path_variable="rvm_archives_path" ; __rvm_set_path_variable "$1"; shift ;;
+ -G) path_variable="rvm_gems_path" ; __rvm_set_path_variable "$next_token"; shift ;;
+ --source) path_variable="rvm_src_path" ; __rvm_set_path_variable "$next_token"; shift ;;
+ --archives) path_variable="rvm_archives_path" ; __rvm_set_path_variable "$next_token"; shift ;;
-h|--help|usage) rvm_action=help ;;
- --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)
- --sdk) rvm_sdk="$1" ; shift ;;
- --archflags) rvm_archflags="$1" ; shift ;;
+ --make) rvm_ruby_make="$next_token" ; shift ;;
+ --make-install) rvm_ruby_make_install="$next_token" ; shift ;;
+ --nice) rvm_niceness="$next_token" ; shift ;;
+ -l|--level) rvm_ruby_patch_level="p$next_token" ; shift ;;
+ # TODO: handle this below better (if $next_token is null)
+ --sdk) rvm_sdk="$next_token" ; shift ;;
+ --archflags) rvm_archflags="$next_token" ; shift ;;
--install) rvm_install_on_use_flag=1 ;;
- --trace) rvm_trace_flag=1 ; set -x ;;
+ --trace)
+ rvm_trace_flag=1
+ if [[ -z "${ZSH_VERSION:-""}" ]] ; then
+ local option="" ;
+ for option in verbose xtrace errexit errtrace noclobber nounset pipefail ; do
+ set -o $option
+ done
+ export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
+ else
+ set -x
+ fi
+ ;;
+ --debug)
+ rvm_debug_flag=1
+ local option="" ;
+ for option in verbose errtrace ; do
+ set -o $option
+ done
+ ;;
-q|--quiet) rvm_quiet_flag=1 ;;
-s|--silent) rvm_silent_flag=1 ;;
- --proxy) rvm_proxy="$1" ; shift ;;
+ --proxy) rvm_proxy="$next_token" ; shift ;;
--disable-llvm|--disable-jit) rvm_llvm_flag=0 ;;
--enable-llvm|--enable-jit) rvm_llvm_flag=1 ;;
reboot|damnit|wtf|argh|BOOM|boom|wth) $rvm_action="reboot" ;;
- --self|--gem|--rubygems|--reconfigure|--default|--debug|--force|--export|--summary|--latest|--yaml|--json|--archive|--shebang|--env|--path|--tail|--delete|--verbose|--import|--rvmrc|--sticky|--create|--gems|--docs)
+ --self|--gem|--rubygems|--reconfigure|--default|--force|--export|--summary|--latest|--yaml|--json|--archive|--shebang|--env|--path|--tail|--delete|--verbose|--import|--rvmrc|--sticky|--create|--gems|--docs)
export "rvm_${rvm_token//-/}_flag"=1
;;
--dump-environment)
- export rvm_dump_environment_flag="$1"; shift
+ export rvm_dump_environment_flag="$next_token"; shift
;;
--clang)
export rvm_clang_flag=1
export rvm_prior_cc="$CC"
export CC="clang"
;;
-j)
- if [[ ! -z "$1" ]] ; then
- rvm_make_flags="$rvm_make_flags -j$1"
+ if [[ ! -z "$next_token" ]] ; then
+ rvm_make_flags="$rvm_make_flags -j$next_token"
shift
else
rvm_action="error"
rvm_error_message="-j *must* be followed by an integer (normally the # of CPU's in your machine)."
fi
;;
--with-rubies)
- rvm_ruby_strings="$1"
+ rvm_ruby_strings="$next_token"
shift
;;
-C|--configure)
- if [[ ! -z "$1" ]] ; then
- rvm_ruby_configure_flags="$(echo $1 | sed -e 's#,--# --#g')"
+ if [[ ! -z "$next_token" ]] ; then
+ rvm_ruby_configure_flags="$(echo $next_token | sed -e 's#,--# --#g')"
shift
else
rvm_action="error"
rvm_error_message="--configure *must* be followed by configure flags."
fi
@@ -360,15 +390,15 @@
--without-*) rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token" ;;
--enable-*) rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token" ;;
--disable-*) rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token" ;;
-I|--include)
- if [[ -z "$1" ]] ; then
+ if [[ -z "$next_token" ]] ; then
rvm_action="error"
rvm_error_message="-I|--include *must* be followed by a path."
else
- rvm_ruby_load_path="$rvm_ruby_load_path:$1"
+ rvm_ruby_load_path="$rvm_ruby_load_path:$next_token"
shift
fi
;;
--) rvm_ruby_args="$*" ; rvm_parse_break=1 ;;
@@ -377,103 +407,130 @@
if [[ -n "$rvm_token" ]] ; then
if [[ "gemset" = "$rvm_action" ]] ; then
if "$rvm_scripts_path/match" "$rvm_token" "^.+${rvm_gemset_separator}.+$" ; then
rvm_gemset_name="${rvm_token/*${rvm_gemset_separator}/}"
rvm_ruby_string="${rvm_token/${rvm_gemset_separator}*/}"
+
elif echo "$rvm_token" | \grep -q '.gems$' ; then
rvm_file_name="${rvm_token/.gems/}.gems" # Account for possible .gems.gems
# elif [[ ! -z "$(echo "$rvm_token" | awk '/\.gems$/')" ]] ; then
else
rvm_gemset_name="${rvm_token/.gems/}"
rvm_file_name="$rvm_gemset_name.gems"
fi
+
elif echo "$rvm_token" | \grep -q ',' ; then
rvm_ruby_strings="$rvm_token"
- if [[ -z "$rvm_action" ]] ; then
+ if [[ -z "${rvm_action:-""}" ]] ; then
rvm_action="ruby" # Not sure if we really want to do this but we'll try it out.
fi
+
elif "$rvm_scripts_path/match" "$rvm_token" "^${rvm_gemset_separator}" ; then
- rvm_action="use"
- rvm_gemset_name="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $2}')"
+ rvm_action="${rvm_action:-use}"
rvm_gemset_name="${rvm_token/*${rvm_gemset_separator}/}"
- rvm_ruby_string="$(__rvm_environment_identifier | awk -F${rvm_gemset_separator} '{print $1}')"
+ rvm_ruby_string="${rvm_ruby_string:-""}"
rvm_ruby_strings="${rvm_ruby_string}${rvm_gemset_separator}${rvm_gemset_name}"
+
elif "$rvm_scripts_path/match" "$rvm_token" "^.+${rvm_gemset_separator}.+$" ; then
- rvm_gemset_name="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $2}')"
- rvm_ruby_string="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $1}')"
+ gemset_name="${rvm_token/*${rvm_gemset_separator}/}"
+ rvm_ruby_string="$rvm_token"
rvm_ruby_strings="$rvm_token"
+
elif "$rvm_scripts_path/match" "$rvm_token" "^.+\\+.+$" ; then
rvm_ruby_alias="${rvm_token/*+/}"
rvm_ruby_string="${rvm_token/+*/}"
rvm_ruby_strings="$rvm_ruby_string"
+
elif "$rvm_scripts_path/match" "$rvm_token" "-" ; then
rvm_ruby_string="$rvm_token"
rvm_ruby_strings="$rvm_token"
+
elif "$rvm_scripts_path/match" "$rvm_token" "^[0-9].[0-9]" ; then
rvm_ruby_string="$rvm_token"
rvm_ruby_strings="$rvm_token"
rvm_action="${rvm_action:-use}"
+
elif "$rvm_scripts_path/match" "$rvm_token" "^ree-" ; then
rvm_ruby_string="$rvm_token"
rvm_ruby_strings="$rvm_token"
rvm_action="${rvm_action:-use}"
+
elif [[ -L "$rvm_rubies_path/$rvm_token" ]] ; then # Alias
rvm_ruby_string=$rvm_token
rvm_ruby_strings="$rvm_token"
rvm_action="${rvm_action:-use}"
+
else
if "$rvm_scripts_path/match" "$rvm_token" ".rb$" ; then # we have a specified ruby script
rvm_ruby_args=$rvm_token
rvm_ruby_file=$rvm_token
- if [[ -z "$rvm_action" ]] ; then rvm_action="ruby" ; fi
+ if [[ -z "${rvm_action:-""}" ]] ; then rvm_action="ruby" ; fi
else
rvm_action="error"
rvm_error_message="Unrecognized command line argument: '$rvm_token'"
fi
fi
else
rvm_action="error"
rvm_error_message="Unrecognized command line argument(s): '$rvm_token $@'"
fi
- if [[ "error" = "$rvm_action" ]] ; then
+
+ if [[ "error" = "${rvm_action:-""}" ]] ; then
break;
fi
esac
- if [[ -z "$rvm_action" ]] && [[ ! -z "$rvm_ruby_string" ]] ; then rvm_action="use" ; fi
- if [[ ! -z "$rvm_parse_break" ]] || [[ ! -z "$rvm_error_message" ]] ; then unset rvm_parse_break; break; fi
+ if [[ -z "${rvm_action:-""}" && -n "${rvm_ruby_string:-""}" ]] ; then rvm_action="use" ; fi
+
+ if [[ ${rvm_parse_break:-0} -eq 1 || -n "${rvm_error_message:-""}" ]] ; then break ; fi
done
+ # Empty args list.
while [[ $# -gt 0 ]] ; do shift ; done
- if [[ ! -z "$rvm_error_message" ]] ; then __rvm_pushpop ; return 1 ; fi
+ if [[ -n "${rvm_error_message:-""}" ]] ; then
+ __rvm_pushpop
+ "$rvm_scripts_path"/log "fail" "$rvm_error_message ( see: 'rvm usage' )"
+ return 1
+ fi
+
}
rvm() {
+ local next_token
+
__rvm_setup
- case $- in *i*) rvm_interactive=1 ;;
- *) unset rvm_interactive ;;
- esac ; export rvm_interactive
+ case $- in *i*) rvm_interactive_flag=1 ;;
+ *) rvm_interactive_flag=0 ;;
+ esac ; export rvm_interactive_flag
- if [[ -z "$ZSH_VERSION" ]] ; then
+ if [[ -z "${ZSH_VERSION:-""}" ]] ; then
trap '\rm -rf "$rvm_tmp_path/$$" >/dev/null 2>&1' 0 1 2 3 15
fi
# Check that this is the current version.
disk_version=$(tail -n 3 < "${rvm_path:-$HOME/.rvm}/lib/VERSION.yml" | sed -e 's/^.*: //g' | \tr "\n" '.' | sed -e 's/\.$//')
- if [[ "${rvm_version}" != "${disk_version}" ]] && [[ "reload" != "$1" ]]; then
+
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; else next_token="" ; fi
+
+ if [[ "${rvm_version}" != "${disk_version}" ]] && [[ "reload" != "$next_token" ]]; then
printf "\nA RVM version ${disk_version} is installed yet ${rvm_version} is loaded.\n Please do one of the following:\n * 'rvm reload'\n * open a new shell\n * source your shell init scripts"
return 1
fi
__rvm_cleanse_variables
__rvm_load_rvmrc
__rvm_initialize
__rvm_parse_args "$@"
- export BUNDLE_PATH GEM_HOME GEM_PATH rvm_ruby_string rvm_action rvm_bin_flag rvm_debug_flag rvm_delete_flag rvm_docs_type rvm_file_name rvm_gemset_name rvm_head_flag rvm_install_on_use_flag rvm_interactive rvm_llvm_flag rvm_make_flags rvm_proxy rvm_remove_flag rvm_ruby_args rvm_ruby_configure_flags rvm_ruby_file rvm_ruby_gem_home rvm_ruby_interpreter rvm_ruby_name rvm_ruby_version rvm_system_flag rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_patch_names rvm_patch_original_pwd rvm_clang_flag rvm_install_arguments
+ rvm_reload_flag=${rvm_reload_flag:-0}
+ rvm_use_flag=${rvm_reload_flag:-0}
+ rvm_delete_flag=${rvm_delete_flag:-0}
+ rvm_action="${rvm_action:-usage}"
+
+ export BUNDLE_PATH GEM_HOME GEM_PATH rvm_ruby_string rvm_action rvm_bin_flag rvm_debug_flag rvm_delete_flag rvm_docs_type rvm_file_name rvm_gemset_name rvm_head_flag rvm_install_on_use_flag rvm_interactive_flag rvm_llvm_flag rvm_make_flags rvm_proxy rvm_remove_flag rvm_ruby_args rvm_ruby_configure_flags rvm_ruby_file rvm_ruby_gem_home rvm_ruby_interpreter rvm_ruby_name rvm_ruby_version rvm_system_flag rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_patch_names rvm_patch_original_pwd rvm_clang_flag rvm_install_arguments
export rvm_path rvm_rubies_path rvm_scripts_path rvm_archives_path rvm_src_path rvm_patches_path rvm_patches_path rvm_patchsets_path rvm_log_path rvm_bin_path rvm_gems_path rvm_config_path rvm_tmp_path rvm_hooks_path rvm_gems_cache_path rvm_gemset_separator rvm_ruby_aliases rvm_quiet_flag rvm_silent_flag
result=0
case "$rvm_action" in
@@ -489,20 +546,17 @@
inspect) __rvm_inspect ; result=$? ;;
implode|seppuku) __rvm_implode ; result=$? ;;
list) "$rvm_scripts_path"/list $rvm_ruby_args ; result=$? ;;
# TODO: Make debug run in the current environment.
- debug) "$rvm_scripts_path"/info '' debug ; result=$? ;;
- help) "$rvm_scripts_path"/help $rvm_ruby_args ; result=$? ;;
- env) "$rvm_scripts_path"/env "$rvm_ruby_string" ; result=$? ;;
+ debug) "$rvm_scripts_path/info" '' debug ; result=$? ;;
+ help) "$rvm_scripts_path/help" $rvm_ruby_args ; result=$? ;;
+ env) "$rvm_scripts_path/env" "$rvm_ruby_string" ; result=$? ;;
info)
- if [[ "$1" = "info" ]]; then shift; fi
- if [[ -z "$rvm_ruby_args" ]] ; then
- "$rvm_scripts_path/info"
- else
- "$rvm_scripts_path/info" $rvm_ruby_args
- fi
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; else next_token="" ; fi
+ if [[ "$next_token" = "info" ]]; then shift; fi
+ "$rvm_scripts_path/info" $rvm_ruby_args
result=$?
;;
answer) __rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything ; result=42 ;;
question) __rvm_ultimate_question ; result=42 ;;
@@ -529,26 +583,26 @@
cleanup|tools|snapshot|disk-usage|repair|alias|docs|rubygems|migrate|upgrade)
__rvm_run_script "$rvm_action" ; result=$?
;;
- rvmrc) eval "__rvm_rvmrc_tools $rvm_ruby_args" ; result="$?" ;;
+ rvmrc) eval "__rvm_rvmrc_tools $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
__rvm_gemset_use
fi
else
export rvm_ruby_strings
- "$rvm_scripts_path"/gemsets $rvm_ruby_args
- unset rvm_ruby_strings
+ "$rvm_scripts_path/gemsets" $rvm_ruby_args ; result=$?
+ rvm_ruby_strings=""
# Clear the gemset.
- if [[ "$rvm_delete_flag" -eq 1 ]] ; then
+ if [[ $rvm_delete_flag -eq 1 ]] ; then
gem_prefix="$(echo $GEM_HOME | sed 's/'${rvm_gemset_separator}'.*$//')"
if [[ "$GEM_HOME" = "${gem_prefix}${rvm_gemset_separator}${rvm_gemset_name}" ]] ; then
rvm_ruby_gem_home="$gem_prefix"
GEM_HOME="$rvm_ruby_gem_home"
BUNDLE_PATH="$rvm_ruby_gem_home"
@@ -563,14 +617,14 @@
monitor)
export rvm_ruby_strings rvm_ruby_string
"$rvm_scripts_path"/monitor ; result=$?
;;
- notes) "$rvm_scripts_path"/notes ; result=$? ;;
- reload) unset rvm_loaded_flag ; rvm_reload_flag=1 ;;
+ notes) "$rvm_scripts_path/notes" ; result=$? ;;
+ reload) rvm_loaded_flag=0 ; rvm_reload_flag=1 ;;
tests|specs) rvm_action="rake" ; __rvm_do ; result=$? ;;
- package) "$rvm_scripts_path"/package $rvm_ruby_args ; result=$? ;;
+ package) "$rvm_scripts_path/package" $rvm_ruby_args ; result=$? ;;
fetch|install|uninstall|remove)
if [[ -n "$rvm_ruby_strings" ]]; then
"$rvm_scripts_path"/manage "$rvm_action" "$rvm_ruby_strings"
else
@@ -578,17 +632,16 @@
fi
result=$?
;;
error)
- "$rvm_scripts_path"/log "fail" "$rvm_error_message ( see: 'rvm usage' )"
__rvm_pushpop
result=1
;;
*)
- if [[ ! -z "$rvm_action" ]] ; then
+ if [[ -n "${rvm_action:-""}" ]] ; then
"$rvm_scripts_path/log" "fail" "unknown action '$rvm_action'"
else
__rvm_usage
fi
result=1
@@ -598,12 +651,15 @@
source "$rvm_scripts_path/rvm"
# Note: Not using builtin on purpose. Done so we can trigger a reload the rvmrc.
__rvm_project_rvmrc
fi
- if [[ ! -z "$rvm_trace_flag" ]] ; then set +x ; unset rvm_trace_flag ; fi
-
__rvm_teardown
+
+ if [[ $rvm_trace_flag -eq 1 ]] ; then
+ set +x
+ rvm_trace_flag=0
+ fi
return $result
}