scripts/cli in rvm-1.0.5 vs scripts/cli in rvm-1.0.6

- old
+ new

@@ -1,8 +1,8 @@ #!/usr/bin/env bash -__rvm_usage() { ${PAGER:-less} "${rvm_path:-$HOME/.rvm}/README" ; } +__rvm_usage() { \less "${rvm_path:-$HOME/.rvm}/README" ; } __rvm_run_script() { local rvm_script_name="${1:-"$rvm_action"}" eval "$rvm_scripts_path/$rvm_script_name $rvm_ruby_args" return $? @@ -228,17 +228,22 @@ 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 - if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi - else - unset rvm_ruby_interpreter rvm_ruby_strings - fi + case "$next_token" in + + ruby|rbx|jruby|macruby|ree|rubinius|maglev|mput|shyouhei|ironruby) + rvm_ruby_strings=$next_token + rvm_ruby_interpreter=$next_token + if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi + ;; + + *) + unset rvm_ruby_interpreter rvm_ruby_strings + ;; + esac fi fi fi ;; @@ -246,11 +251,11 @@ rvm_action="benchmark" ;; specs|tests) rvm_action="rake" - rvm_ruby_args="$(echo "$rvm_token" | sed -e 's/s$//')" + rvm_ruby_args="${rvm_token/%ss/s}" ;; -v|--version) if [[ -z "$next_token" ]] ; then rvm_action="version" @@ -407,23 +412,28 @@ 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 export PS4='+${BASH_SOURCE} : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() : }' fi fi ;; @@ -474,23 +484,23 @@ ;; -C|--configure) if [[ ! -z "$next_token" ]] ; then - rvm_ruby_configure_flags="$(echo $next_token | sed -e 's#,--# --#g')" + rvm_configure_flags="${next_token//,--/ --}" 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 ;; - --with-*) rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token" ;; - --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" ;; + --with-*) rvm_configure_flags="${rvm_configure_flags:-""} $rvm_token" ;; + --without-*) rvm_configure_flags="${rvm_configure_flags:-""} $rvm_token" ;; + --enable-*) rvm_configure_flags="${rvm_configure_flags:-""} $rvm_token" ;; + --disable-*) rvm_configure_flags="${rvm_configure_flags:-""} $rvm_token" ;; -I|--include) if [[ -z "$next_token" ]] ; then rvm_action="error" rvm_error_message="-I|--include *must* be followed by a path." @@ -589,10 +599,11 @@ return 1 fi } rvm() { + local next_token __rvm_setup case $- in *i*) rvm_interactive_flag=1 ;; @@ -602,26 +613,30 @@ 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/\.$//') + disk_version="$(awk '/:/{printf $NF"."}' "$rvm_path/lib/VERSION.yml")" + disk_version="${disk_version/%.}" if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi - if [[ "${rvm_version}" != "${disk_version}" ]] && [[ "reload" != "$next_token" ]]; then + 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 "$@" 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 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 + 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_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_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 use) __rvm_use ; result=$? ;;