scripts/selector in rvm-1.0.4 vs scripts/selector in rvm-1.0.5

- old
+ new

@@ -2,27 +2,18 @@ # __rvm_select implementation version patch_level __rvm_select() { # Set Variable Defaults - rvm_ruby_interpreter=${rvm_ruby_interpreter:-""} - rvm_head_flag=${rvm_head_flag:-0} - rvm_install_on_use_flag=${rvm_install_on_use_flag:-0} - rvm_ruby_version=${rvm_ruby_version:-""} - rvm_ruby_patch_level=${rvm_ruby_patch_level:-""} - rvm_ruby_revision=${rvm_ruby_revision:-""} - rvm_ruby_name=${rvm_ruby_name:-""} - rvm_ruby_gem_home=${rvm_ruby_gem_home:-""} - export GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION if [[ -z "${rvm_ruby_string:-""}" ]] ; then - rvm_ruby_string="${rvm_ruby_interpreter}" - [[ -n "$rvm_ruby_version" ]] && rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_version" - [[ -n "$rvm_ruby_patch_level" ]] && rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_patch_level" - [[ -n "$rvm_ruby_revision" ]] && rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_revision" - [[ -n "$rvm_ruby_name" ]] && rvm_ruby_name="$rvm_ruby_string-n$rvm_ruby_name" + [[ -n "${rvm_ruby_interpreter:-""}" ]] && rvm_ruby_string="$rvm_ruby_interpreter" + [[ -n "${rvm_ruby_version:-""}" ]] && rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_version" + [[ -n "${rvm_ruby_patch_level:-""}" ]] && rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_patch_level" + [[ -n "${rvm_ruby_revision:-""}" ]] && rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_revision" + [[ -n "${rvm_ruby_name:-""}" ]] && rvm_ruby_name="$rvm_ruby_string-n$rvm_ruby_name" fi __rvm_ruby_string rvm_archive_extension="tar.gz" @@ -31,27 +22,27 @@ macruby) if [[ "Darwin" = "$(uname)" ]] ; then rvm_ruby_package_name=${rvm_ruby_interpreter}-${rvm_ruby_version} - if [[ $rvm_head_flag -eq 1 ]] ; then + if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then rvm_ruby_version="" ; rvm_ruby_tag="" rvm_ruby_revision="head" __rvm_db "macruby_repo_url" "rvm_ruby_repo_url" - rvm_url="$rvm_ruby_repo_url" + rvm_ruby_url="$rvm_ruby_repo_url" - elif [[ "nightly" = "$rvm_ruby_version" ]] ; then - __rvm_db "macruby_nightly_url" "rvm_url" + elif [[ "nightly" = "${rvm_ruby_version:-""}" ]] ; then + __rvm_db "macruby_nightly_url" "rvm_ruby_url" rvm_ruby_package_name="${rvm_ruby_interpreter}_nightly-${rvm_ruby_version}" rvm_ruby_package_file="$rvm_ruby_package_name" else __rvm_db "macruby_version" "rvm_ruby_version" - __rvm_db "macruby_url" "rvm_url" + __rvm_db "macruby_url" "rvm_ruby_url" rvm_ruby_package_name="MacRuby%20${rvm_ruby_version}.zip" rvm_ruby_package_file="$rvm_ruby_package_name" - rvm_url="$rvm_url/$rvm_ruby_package_name" + rvm_ruby_url="$rvm_ruby_url/$rvm_ruby_package_name" fi rvm_ruby_patch_level="" else "$rvm_scripts_path/log" "fail" "MacRuby can only be installed on a Darwin OS." fi @@ -61,38 +52,38 @@ rvm_archive_extension="tar.gz" rvm_ruby_interpreter="rbx" rvm_ruby_version=${rvm_ruby_version:-$(__rvm_db "rbx_version")} rvm_ruby_repo_url=${rvm_rbx_repo_url:-$(__rvm_db "rubinius_repo_url")} - if [[ $rvm_head_flag -eq 0 ]] ; then + if [[ ${rvm_head_flag:-0} -eq 0 ]] ; then rvm_ruby_patch_level=${rvm_ruby_patch_level:-$(__rvm_db "rbx_patch_level")} rvm_ruby_string="${rvm_ruby_string/-prc/-rc}" rvm_ruby_string="$(echo "$rvm_ruby_string" | sed 's#-p*#-#')" rvm_ruby_package_file="$(echo "rubinius-${rvm_ruby_version}-${rvm_ruby_patch_level}.${rvm_archive_extension}" | sed 's#-p*#-#' )" - __rvm_db "rbx_url" "rvm_url" - rvm_url="$rvm_url/$rvm_ruby_package_file" + __rvm_db "rbx_url" "rvm_ruby_url" + rvm_ruby_url="$rvm_ruby_url/$rvm_ruby_package_file" else rvm_ruby_patch_level="" ; rvm_ruby_version="" fi ;; jruby) rvm_ruby_patch_level="" - if [[ $rvm_head_flag -eq 1 ]] ; then + if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then rvm_ruby_version="head" rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "jruby_repo_url")}" - rvm_url="${rvm_ruby_repo_url:-$(__rvm_db "jruby_repo_url")}" + rvm_ruby_url="${rvm_ruby_repo_url:-$(__rvm_db "jruby_repo_url")}" else rvm_archive_extension="tar.gz" rvm_ruby_version="${rvm_ruby_version:-"$(__rvm_db "jruby_version")"}" jruby_url="$(__rvm_db "jruby_url")" rvm_ruby_package_file="${rvm_ruby_interpreter}-bin-${rvm_ruby_version}" rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}" - rvm_url="${jruby_url}/${rvm_ruby_version}/${rvm_ruby_package_file}.tar.gz" + rvm_ruby_url="${jruby_url}/${rvm_ruby_version}/${rvm_ruby_package_file}.tar.gz" jruby_url="" fi alias jruby_ng="jruby --ng" alias jruby_ng_server="jruby --ng-server" @@ -100,23 +91,23 @@ maglev) rvm_ruby_patch_level="" maglev_url="$(__rvm_db "maglev_url")" - if [[ $rvm_head_flag -eq 1 ]] ; then + if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then rvm_ruby_version="head" rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "maglev_repo_url")}" - rvm_url="${rvm_ruby_repo_url:-$(__rvm_db "maglev_repo_url")}" + rvm_ruby_url="${rvm_ruby_repo_url:-$(__rvm_db "maglev_repo_url")}" else system="$(uname -s)" arch="$(uname -m)" rvm_ruby_package_file="MagLev-${rvm_ruby_version}.${system}-${arch}" rvm_gemstone_package_file="GemStone-${rvm_ruby_version}.${system}-${arch}" rvm_ruby_version="${rvm_ruby_version:-"$(__rvm_db "maglev_version")"}" rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}" - rvm_url="${rvm_ruby_url:-"$maglev_url/${rvm_ruby_package_file}.${rvm_archive_extension}"}" + rvm_ruby_url="${rvm_ruby_url:-"$maglev_url/${rvm_ruby_package_file}.${rvm_archive_extension}"}" rvm_gemstone_url="${rvm_gemstone_url:-"$maglev_url/${rvm_gemstone_package_file}.${rvm_archive_extension}"}" export MAGLEV_HOME="$rvm_rubies_path/$rvm_ruby_string" fi ;; @@ -125,39 +116,40 @@ if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then rvm_ruby_version="head" rvm_ruby_package_name="${rvm_ruby_string}" rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "ironruby_repo_url")}" - rvm_url="${rvm_ruby_repo_url:-$(__rvm_db "ironruby_repo_url")}" + rvm_ruby_url="${rvm_ruby_repo_url:-$(__rvm_db "ironruby_repo_url")}" else rvm_archive_extension="zip" rvm_ruby_version=${rvm_ruby_version:-"$(__rvm_db "ironruby_version")"} rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}" rvm_ruby_package_file="${rvm_ruby_interpreter}-${rvm_ruby_version}.${rvm_archive_extension}" - rvm_url="$(__rvm_db "ironruby_${rvm_ruby_version}_url")${rvm_ruby_package_file}" + rvm_ruby_url="$(__rvm_db "ironruby_${rvm_ruby_version}_url")${rvm_ruby_package_file}" fi - export rvm_ruby_version rvm_ruby_string rvm_ruby_package_name rvm_ruby_repo_url rvm_url rvm_archive_extension + export rvm_ruby_version rvm_ruby_string rvm_ruby_package_name rvm_ruby_repo_url rvm_ruby_url rvm_archive_extension ;; ree) rvm_ruby_interpreter=ree rvm_ruby_version=${rvm_ruby_version:-"$(__rvm_db "ree_version")"} - if [[ ! -z "$rvm_ruby_patch_level" ]] ; then + if [[ -n "${rvm_ruby_patch_level:-0}" ]] ; then rvm_ruby_patch_level="$(echo $rvm_ruby_patch_level | sed 's#^p##')" fi - if [[ "$rvm_ruby_version" != "head" ]] ; then - if [[ ! -z "$rvm_ruby_revision" ]] ; then + if [[ ${rvm_head_flag:-0} -eq 0 ]] ; then + + if [[ -n "${rvm_ruby_revision:-""}" ]] ; then rvm_ruby_patch_level="" ; rvm_ruby_package_file="" rvm_ruby_package_name="ree-$rvm_ruby_version-$rvm_ruby_revision" else 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" + rvm_ruby_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" @@ -168,11 +160,11 @@ rvm_ruby_interpreter="mput" rvm_ruby_version="head" rvm_ruby_string=$(echo $rvm_ruby_string | sed -e 's/shyouhei/mput/g') rvm_ruby_patch_level="" rvm_ruby_repo_url=${rvm_mput_repo_url:-"$(__rvm_db "shyouhei_repo_url")"} - rvm_url=$rvm_ruby_repo_url + rvm_ruby_url=$rvm_ruby_repo_url rvm_ruby_configure="" ; rvm_ruby_make="" ; rvm_ruby_make_install="" ;; ruby) if [[ -z "${rvm_ruby_version:-""}" && ${rvm_head_flag:-0} -eq 0 ]]; then @@ -197,20 +189,20 @@ rvm_ruby_interpreter="system" fi ;; default|system|user) - #no-op? + # no-op? ;; *) - if [[ ! -z "$MY_RUBY_HOME" ]] ; then + if [[ -n "${MY_RUBY_HOME:-""}" ]] ; then rvm_ruby_string=$(basename $MY_RUBY_HOME) __rvm_select else - if [[ -z "$rvm_ruby_string" ]] ; then + if [[ -z "${rvm_ruby_string:-""}" ]] ; then "$rvm_scripts_path/log" "fail" "Ruby implementation '$rvm_ruby_interpreter' is not known." return 1 fi fi esac @@ -218,13 +210,13 @@ __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="${rvm_ruby_version/.*/}" - rvm_major_version=${rvm_ruby_version%.*} ; rvm_major_version=${rvm_major_version#*.} - rvm_minor_version="${rvm_ruby_version//*.}" + rvm_ruby_release_version="${rvm_ruby_version/.*/}" + rvm_ruby_major_version=${rvm_ruby_version%.*} ; rvm_ruby_major_version=${rvm_ruby_major_version#*.} + rvm_ruby_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,35 +239,32 @@ rvm_ruby_selected_flag=1 \mkdir -p "$rvm_ruby_log_path" - export rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_package_name rvm_url rvm_ruby_patch_level rvm_ruby_configure rvm_ruby_configure_flags rvm_ruby_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_release_version rvm_major_version rvm_minor_version rvm_gemset_name rvm_gems_path rvm_ruby_gem_home rvm_path rvm_src_path rvm_bin_path rvm_ruby_binary rvm_ruby_home rvm_log_path rvm_ruby_log_path rvm_src_path rvm_ruby_src_path rvm_ruby_irbrc rvm_ruby_selected_flag rvm_ruby_string + export rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_url rvm_ruby_patch_level rvm_ruby_configure rvm_ruby_configure_flags rvm_ruby_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_ruby_release_version rvm_ruby_major_version rvm_ruby_minor_version rvm_gemset_name rvm_gems_path rvm_ruby_gem_home rvm_path rvm_src_path rvm_bin_path rvm_ruby_binary rvm_ruby_home rvm_log_path rvm_ruby_log_path rvm_src_path rvm_ruby_src_path rvm_ruby_irbrc rvm_ruby_selected_flag rvm_ruby_string else rvm_ruby_interpreter="${rvm_ruby_interpreter:-system}" fi } __rvm_use() { - - rvm_ruby_selected_flag=${rvm_ruby_selected_flag:-0} rvm_head_flag=${rvm_head_flag:-0} rvm_default_flag=${rvm_default_flag:-0} rvm_rvmrc_flag=${rvm_rvmrc_flag:-0} rvm_verbose_flag=${rvm_verbose_flag:-0} rvm_sticky_flag=${rvm_sticky_flag:-0} - rvm_ruby_interpreter="${rvm_ruby_interpreter:-""}" rvm_gemset_name="${rvm_gemset_name:-""}" rvm_ruby_gem_home="${rvm_ruby_gem_home:-""}" rvm_wrapper_name="${rvm_wrapper_name:-""}" rvm_ruby_alias="${rvm_ruby_alias:-""}" local new_path="" - if [[ $rvm_ruby_selected_flag -eq 0 ]] ; then __rvm_select "$@" ; fi + if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select "$@" ; fi - if [[ -z "$rvm_ruby_interpreter" ]] ; then rvm_ruby_interpreter="system" ; fi + if [[ -z "${rvm_ruby_interpreter:-""}" ]] ; then rvm_ruby_interpreter="system" ; fi if [[ "system" = "$rvm_ruby_interpreter" ]] ; then unset GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION IRBRC @@ -302,11 +291,11 @@ [[ -L "$full_binary_path" ]] && \rm -f "$full_binary_path" done fi - [[ ${rvm_verbose_flag:-0} -eq 1 ]] && "$rvm_scripts_path/log" "info" "Now using system ruby." + [[ ${rvm_verbose_flag:-0} -gt 0 ]] && "$rvm_scripts_path/log" "info" "Now using system ruby." export rvm_ruby_string="system" else GEM_HOME="$rvm_ruby_gem_home" @@ -331,11 +320,11 @@ fi # Ensure the environment file for the selected ruby exists. __rvm_ensure_has_environment_files - [[ ${rvm_verbose_flag:-0} -eq 1 ]] && \ + [[ ${rvm_verbose_flag:-0} -gt 0 ]] && \ "$rvm_scripts_path/log" "info" "Using $(basename $GEM_HOME | \tr '-' ' ' | sed 's/'${rvm_gemset_separator}'/ with gemset /')" 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 @@ -427,13 +416,11 @@ rvm_ruby_string="${rvm_ruby_string/${rvm_gemset_separator}*/}" rvm_sticky_flag=1 fi # Alias'd rubies - if [[ ${rvm_expanding_aliases:-0} -eq 0 ]]; then - rvm_ruby_string="${rvm_ruby_string:-"default"}" - + if [[ ${rvm_expanding_aliases:-0} -eq 0 && -n ${rvm_ruby_string:-""} ]]; then if expanded_alias_name="$("$rvm_scripts_path/alias" show "$rvm_ruby_string" 2>/dev/null)" && [[ -n "$expanded_alias_name" ]] ; then rvm_ruby_string="$expanded_alias_name" elif [[ "$rvm_ruby_string" = default ]]; then # Default is not a known value. Instead, we need to therefore set it to system. @@ -712,11 +699,11 @@ "$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_flag:-0} -eq 1 && ${rvm_verbose_flag:-1} -ne 0 ]] ; then + if [[ ${rvm_interactive_flag:-0} -gt 0 && ${rvm_verbose_flag:-1} -ne 0 ]] ; then "$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}" GEM_HOME="$rvm_ruby_gem_home" @@ -729,12 +716,12 @@ return 0 } __rvm_gemset_clear() { - 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_gemset_name="" ; shift # TODO: Is this shift necessary??? + 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.