scripts/cli in rvm-1.0.4 vs scripts/cli in rvm-1.0.5
- old
+ new
@@ -20,33 +20,34 @@
export rvm_ruby_string="${rvm_ruby_string:-""}"
local rvm_parse_break=0
local rvm_error_message=""
- while [[ $# -gt 0 ]] ; do
- rvm_token="$next_token" ; shift
+ while [[ -n "$next_token" ]] ; do
+ rvm_token="$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
- 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 [[ "$next_token" = "--only-path" ]]; then
shift; rvm_only_path_flag=1
fi
- rvm_ruby_args="$*"
+ rvm_ruby_args="$next_token $*"
rvm_parse_break=1
;;
use)
rvm_action="$rvm_token"
rvm_verbose_flag=1
- if [[ "ruby" = "$next_token" ]] ; then shift ; fi
+ if [[ "ruby" = "$next_token" ]] ; then
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ fi
;;
install|uninstall)
export ${rvm_token}_flag=1
rvm_action=$rvm_token
@@ -63,13 +64,20 @@
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 "$next_token" "^[0-9]\.[0-9]" ; then rvm_ruby_version=$next_token ; shift ; fi
+ if "$rvm_scripts_path"/match "$next_token" "^[0-9]\.[0-9]" ; then
+ rvm_ruby_version=$next_token
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ fi
;;
+ default)
+
+ ;;
+
gemset)
rvm_action=$rvm_token
rvm_ruby_gem_home="$GEM_HOME"
@@ -80,15 +88,15 @@
__rvm_gemset_clear
rvm_ruby_args="clear"
elif [[ "use" = "$next_token" ]] ; then
rvm_use_flag=1
- rvm_ruby_args="$@"
+ rvm_ruby_args="$next_token $@"
rvm_gemset_name="$next_token"
- shift # Clear next_token
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
- if [[ $# -gt 0 ]] ; then rvm_gemset_name="$1" ; else rvm_gemset_name="" ; fi
+ if [[ -n "$next_token" ]] ; then rvm_gemset_name="$next_token" ; else rvm_gemset_name="" ; fi
if echo $rvm_gemset_name | \grep -q $rvm_gemset_separator ; then
rvm_ruby_string=$(echo $rvm_gemset_name | sed -e 's/\(.*\)'${rvm_gemset_separator}'.*/\1/')
rvm_gemset_name=$(echo $rvm_gemset_name | sed -e 's/.*'${rvm_gemset_separator}'\(.*\)/\1/')
@@ -99,12 +107,15 @@
rvm_ruby_gem_home="$rvm_ruby_gem_home${rvm_gemset_separator}$rvm_gemset_name"
fi
elif [[ "delete" = "$next_token" ]] ; then
rvm_delete_flag=1
- rvm_ruby_args="$@" ; shift
- rvm_gemset_name="$next_token"; shift
+ rvm_ruby_args="$next_token $@"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ rvm_gemset_name="$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+
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"
@@ -113,55 +124,64 @@
fi
else
rvm_gemset_name="${rvm_gemset_name:-""}"
if [[ "$rvm_ruby_string" != "$rvm_gemset_name" ]] ; then __rvm_ruby_string ; fi
- rvm_ruby_args="$@"
+ rvm_ruby_args="$next_token $@"
fi
+
rvm_parse_break=1
;;
gemdir|gempath|gemhome)
rvm_action=$rvm_token
rvm_gemdir_flag=1
- if [[ "system" = "$next_token" ]] ; then rvm_system_flag=1 ; shift ; fi
- if [[ "user" = "$next_token" ]] ; then rvm_user_flag=1 ; shift ; fi
+
+ if [[ "system" = "$next_token" ]] ; then
+ rvm_system_flag=1
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ fi
+
+ if [[ "user" = "$next_token" ]] ; then
+ rvm_user_flag=1
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ fi
;;
inspect|list|info|strings)
rvm_action="$rvm_token"
- rvm_ruby_args="$@"
+ rvm_ruby_args="$next_token $@"
rvm_parse_break=1
;;
-S)
rvm_action="ruby"
- rvm_ruby_args="$rvm_token $(__rvm_quote_args "$@")"
+ rvm_ruby_args="$rvm_token $next_token $(__rvm_quote_args "$@")"
rvm_parse_break=1
;;
-e)
rvm_action="ruby"
- rvm_ruby_args="$rvm_token $(__rvm_quote_args "$@")"
+ rvm_ruby_args="$rvm_token $next_token $(__rvm_quote_args "$@")"
rvm_parse_break=1
;;
docs|alias|rubygems|exec|cleanup|tools|disk-usage|snapshot|repair|migrate|upgrade)
rvm_action="$rvm_token"
- rvm_ruby_args="$(__rvm_quote_args "$@")"
+ rvm_ruby_args="$next_token $(__rvm_quote_args "$@")"
rvm_parse_break=1
;;
load-rvmrc)
rvm_action="rvmrc"
- rvm_ruby_args="'load' $(__rvm_quote_args "$@")"
+ rvm_ruby_args="'load' $next_token $(__rvm_quote_args "$@")"
rvm_parse_break=1
;;
rvmrc)
rvm_action="rvmrc"
- rvm_ruby_args="$(__rvm_quote_args "$@")"
+ rvm_ruby_args="$next_token $(__rvm_quote_args "$@")"
rvm_parse_break=1
;;
do|ruby|rake|gem|rubydo|rakedo|gemdo)
if [[ "do" = "${rvm_action:-""}" ]] ; then rvm_action="ruby" ; fi
@@ -185,36 +205,37 @@
fi
fi
elif [[ "-S" = "$next_token" ]] ; then
rvm_action="ruby"
- rvm_ruby_args="$flag $(__rvm_quote_args "$@")"
+ rvm_ruby_args="$flag $next_token $(__rvm_quote_args "$@")"
rvm_parse_break=1
elif [[ "-e" = "$next_token" ]] ; then
rvm_action="ruby"
- rvm_ruby_args="$flag $(__rvm_quote_args "$@")"
+ rvm_ruby_args="$flag $next_token $(__rvm_quote_args "$@")"
rvm_parse_break=1
else
- rvm_ruby_args="$(__rvm_quote_args "$@")"
+ rvm_ruby_args="$next_token $@"
rvm_parse_break=1
fi
else
if "$rvm_scripts_path"/match "$next_token" "^-" ; then
unset rvm_ruby_strings
else
if "$rvm_scripts_path"/match "$next_token" "^[0-9]" ; then
- rvm_ruby_strings="${1//,/ }" ; shift
+ rvm_ruby_strings="${1//,/ }"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
unset rvm_ruby_interpreter
else
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
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
else
unset rvm_ruby_interpreter rvm_ruby_strings
fi
fi
fi
@@ -225,57 +246,61 @@
rvm_action="benchmark"
;;
specs|tests)
rvm_action="rake"
- rvm_ruby_args="$(echo $rvm_token | sed -e 's/s$//')"
+ rvm_ruby_args="$(echo "$rvm_token" | sed -e 's/s$//')"
;;
-v|--version)
if [[ -z "$next_token" ]] ; then
rvm_action="version"
else
rvm_ruby_version="$next_token"
- shift
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
fi
;;
--repository|--repo|--url)
rvm_ruby_repo_url=$rvm_token
;;
--ree-options)
if [[ ! -z "$next_token" ]] ; then
- export rvm_ree_options="${1//,/ }" ; shift
+ export rvm_ree_options="${1//,/ }"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+
else
rvm_action="error"
rvm_error_message="--ree-options *must* be followed by... well... options."
fi
;;
--patches|--patch)
- rvm_patch_names="$next_token ${rvm_patch_names:-""}"; shift
+ rvm_patch_names="$next_token ${rvm_patch_names:-""}"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
rvm_patch_original_pwd="$PWD"
;;
--head) rvm_head_flag=1 ;;
--bin)
if [[ "update" = "${rvm_action:-""}" ]] ; then
rvm_bin_flag=1
else
- rvm_bin_path="$next_token" ; shift
+ rvm_bin_path="$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
fi
;;
-r|--require)
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$next_token"
- shift
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
fi
;;
--rdoc|--yard)
rvm_docs_type="$rvm_token"
@@ -283,11 +308,11 @@
;;
-f|--file)
rvm_action="ruby"
rvm_ruby_file="$next_token"
- shift
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
;;
system|default)
rvm_action=${rvm_action:-use}
rvm_ruby_interpreter="$rvm_token"
@@ -295,85 +320,137 @@
rvm_ruby_strings="$rvm_token"
;;
help)
rvm_action="$rvm_token"
- rvm_ruby_args="$@"
+ rvm_ruby_args="$next_token $@"
rvm_parse_break=1
;;
--passenger|--editor)
rvm_wrapper_name="${rvm_token/--/}"
;;
--alias)
if [[ -n "$next_token" ]]; then
rvm_ruby_aliases="$(echo "${rvm_ruby_aliases//,/ } ${1//,/ }" | __rvm_strip)"
- shift
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
fi
;;
--symlink)
"$rvm_scripts_path/log" "warn" "--symlink has been removed, please see 'rvm wrapper'."
- shift
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
;;
wrapper)
rvm_action="$rvm_token"
rvm_ruby_string="$next_token" ;
- [[ -n "$next_token" ]] && shift
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
rvm_wrapper_name="$next_token"
- [[ -n "$next_token" ]] && shift
- rvm_ruby_args="$@" # list of binaries, or none
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ rvm_ruby_args="$next_token $@" # list of binaries, or none
rvm_parse_break=1
;;
- -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="$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)
+ -G)
+ path_variable="rvm_gems_path"
+ __rvm_set_path_variable "$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ ;;
+
+ --source)
+ path_variable="rvm_src_path"
+ __rvm_set_path_variable "$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ ;;
+
+ --archives)
+ path_variable="rvm_archives_path"
+ __rvm_set_path_variable "$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ ;;
+
+ -h|--help|usage)
+ rvm_action=help
+ ;;
+
+ --make)
+ rvm_ruby_make="$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ ;;
+ --make-install)
+ rvm_ruby_make_install="$next_token" ; shift
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ ;;
+
+ --nice)
+ rvm_niceness="$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ ;;
+
+ -l|--level)
+ rvm_ruby_patch_level="p$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ ;;
+
+ --sdk)
+ rvm_sdk="$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ ;;
+
+ --archflags)
+ rvm_archflags="$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ ;;
+
+ --install)
+ rvm_install_on_use_flag=1
+ ;;
+
+ --trace|--debug)
+ local option=""
+ rvm_debug_flag=1
+
+ for option in verbose errexit noclobber nounset ; do
+ set -o $option
+ done
+ if [[ -z "${ZSH_VERSION:-""}" ]] ; then
+ set -o errtrace
+ set -o pipefail
+ fi
+
+ if [[ "$rvm_token" = "--trace" ]] ; then
rvm_trace_flag=1
+ set -o xtrace
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
+ export PS4='+${BASH_SOURCE} : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() : }'
fi
- ;;
- --debug)
- rvm_debug_flag=1
- local option="" ;
- for option in verbose errtrace ; do
- set -o $option
- done
+ fi
;;
+
-q|--quiet) rvm_quiet_flag=1 ;;
+
-s|--silent) rvm_silent_flag=1 ;;
- --proxy) rvm_proxy="$next_token" ; shift ;;
+
+ --proxy)
+ rvm_proxy="$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+ ;;
+
--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|--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="$next_token"; shift
+ export rvm_dump_environment_flag="$next_token"
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
;;
--clang)
export rvm_clang_flag=1
export rvm_prior_cc="$CC"
@@ -381,26 +458,29 @@
;;
-j)
if [[ ! -z "$next_token" ]] ; then
rvm_make_flags="$rvm_make_flags -j$next_token"
- shift
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+
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="$next_token"
- shift
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+
;;
-C|--configure)
if [[ ! -z "$next_token" ]] ; then
rvm_ruby_configure_flags="$(echo $next_token | sed -e 's#,--# --#g')"
- shift
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
+
else
rvm_action="error"
rvm_error_message="--configure *must* be followed by configure flags."
fi
;;
@@ -414,15 +494,15 @@
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:$next_token"
- shift
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
fi
;;
- --) rvm_ruby_args="$*" ; rvm_parse_break=1 ;;
+ --) rvm_ruby_args="$next_token $*" ; rvm_parse_break=1 ;;
*)
if [[ -n "$rvm_token" ]] ; then
if [[ "gemset" = "$rvm_action" ]] ; then
if "$rvm_scripts_path/match" "$rvm_token" "^.+${rvm_gemset_separator}.+$" ; then
@@ -478,12 +558,12 @@
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
+ rvm_ruby_args="$rvm_token"
+ rvm_ruby_file="$rvm_token"
if [[ -z "${rvm_action:-""}" ]] ; then rvm_action="ruby" ; fi
else
rvm_action="error"
rvm_error_message="Unrecognized command line argument: '$rvm_token'"
fi
@@ -491,13 +571,11 @@
else
rvm_action="error"
rvm_error_message="Unrecognized command line argument(s): '$rvm_token $@'"
fi
- if [[ "error" = "${rvm_action:-""}" ]] ; then
- break;
- fi
+ if [[ "error" = "${rvm_action:-""}" ]] ; then break ; fi
esac
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
@@ -505,15 +583,13 @@
# Empty args list.
while [[ $# -gt 0 ]] ; do shift ; done
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
@@ -528,11 +604,11 @@
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 [[ $# -gt 0 ]] ; then next_token="$1" ; else next_token="" ; fi
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; 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
@@ -565,11 +641,11 @@
# 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=$? ;;
info)
- if [[ $# -gt 0 ]] ; then next_token="$1" ; else next_token="" ; fi
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
if [[ "$next_token" = "info" ]]; then shift; fi
"$rvm_scripts_path/info" $rvm_ruby_args
result=$?
;;
@@ -587,11 +663,11 @@
ruby|gem|rake|exec)
old_rvm_ruby_string=$rvm_ruby_string
unset rvm_ruby_string
export rvm_ruby_strings
- "$rvm_scripts_path/set" "$rvm_action" "$rvm_ruby_args"
+ "$rvm_scripts_path/set" "$rvm_action" $rvm_ruby_args
result=$?
# Restore the state pre-sets.
[[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string
unset old_rvm_ruby_string
;;
@@ -650,10 +726,9 @@
fi
result=$?
;;
error)
- __rvm_pushpop
result=1
;;
*)
if [[ -n "${rvm_action:-""}" ]] ; then