scripts/selector in rvm-0.0.66 vs scripts/selector in rvm-0.0.67
- old
+ new
@@ -1,18 +1,17 @@
#!/bin/bash
# __rvm_select implementation version patch_level
function __rvm_select {
if [[ -z "$rvm_ruby_string" ]] ; then
- rvm_ruby_string="$rvm_ruby_interpreter"
+ rvm_ruby_string="${rvm_ruby_interpreter}"
if [[ ! -z "$rvm_ruby_version" ]] ; then rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_version" ; fi
if [[ ! -z "$rvm_ruby_patch_level" ]] ; then rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_patch_level" ; fi
if [[ ! -z "$rvm_ruby_revision" ]] ; then rvm_ruby_string="$rvm_ruby_string-$rvm_ruby_revision" ; fi
fi
+
__rvm_ruby_string
- if [[ "1.8" = "$rvm_ruby_version" ]] ; then rvm_ruby_version="1.8.6" ; fi
- if [[ "1.9" = "$rvm_ruby_version" ]] ; then rvm_ruby_version="1.9.1" ; fi
case "$rvm_ruby_interpreter" in
macruby)
if [[ "Darwin" = "$(uname)" ]] ; then
rvm_ruby_repo_url="${rvm_ruby_repo_url:-"$(__rvm_db "macruby_repo_url")"}"
@@ -28,14 +27,13 @@
;;
rbx|rubinius)
rvm_ruby_interpreter="rbx"
rvm_ruby_version="${rvm_ruby_version:-head}"
- #rvm_ruby_revision="head"
unset rvm_ruby_patch_level
rvm_ruby_repo_url=${rvm_rbx_repo_url:-"$(__rvm_db "rubinius_repo_url")"}
- rvm_ruby_string="rbx-head"
+ rvm_ruby_string="rbx-head" # for now :)
rvm_url=$rvm_ruby_repo_url
rvm_ruby_configure=""
rvm_ruby_make="build"
rvm_ruby_make_install=""
;;
@@ -55,29 +53,30 @@
rvm_url="http://dist.codehaus.org/$rvm_ruby_interpreter/$rvm_ruby_version/$rvm_package_file.tar.gz"
alias jruby_ng="jruby --ng"
alias jruby_ng_server="jruby --ng-server"
;;
- ruby-enterprise|ree)
+ ree)
rvm_ruby_interpreter=ree
rvm_ruby_version=${rvm_ruby_version:-"$(__rvm_db "ree_version")"}
- if [[ -z "$rvm_ruby_patch_level" ]] ; then
- rvm_ruby_patch_level="${rvm_ruby_patch_level:-$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_patch_level")}"
- else
+ if [[ ! -z "$rvm_ruby_patch_level" ]] ; then
rvm_ruby_patch_level="$(echo $rvm_ruby_patch_level | sed 's#^p##')"
+ rvm_ruby_string="${rvm_ruby_interpreter}-${rvm_ruby_version}-${rvm_ruby_patch_level}"
+ elif [[ "$rvm_head_flag" = 1 ]] ; then
+ rvm_ruby_string="${rvm_ruby_interpreter}-${rvm_ruby_version}-head"
fi
- rvm_ruby_string="${rvm_ruby_interpreter}-${rvm_ruby_version}-${rvm_ruby_patch_level}"
if [[ "$rvm_ruby_version" != "head" ]] ; then
if [[ ! -z "$rvm_ruby_revision" ]] ; then
unset 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_url:-$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_url")}/$rvm_ruby_package_file.tar.gz"
fi
fi
+
if ! match "$rvm_ruby_version" "^1\.8" ; then
__rvm_log "fail" "Unknown Ruby Enterprise Edition version: $rvm_ruby_version"
fi
;;
@@ -90,19 +89,11 @@
rvm_url=$rvm_ruby_repo_url
unset rvm_ruby_configure rvm_ruby_make rvm_ruby_make_install
;;
ruby)
- if [[ ! -z "$rvm_ruby_tag" ]] ; then
- rvm_ruby_version=$(echo $rvm_ruby_tag | sed 's#^v##' | sed 's#/##' | awk -F'_' '{print 1 "." $2 "." $3 }')
- # rvm_ruby_patch_level=$rvm_ruby_tag # $(echo $rvm_ruby_tag | sed 's#^v##' | sed 's#/##' | awk -F'_' '{print $4 }')
- if [[ -z "$rvm_ruby_patch_level" ]] ; then rvm_ruby_patch_level=$rvm_ruby_tag ; fi
- fi
- if [[ ! -z "$rvm_head_flag" ]] ; then rvm_ruby_repo_url="${rvm_ruby_repo_url:-"$(__rvm_db "ruby_repo_url")"}" ; fi
- if [[ -z "$rvm_ruby_version" ]] ; then rvm_ruby_version=$(__rvm_db "ruby_version") ; fi
- if [[ -z "$rvm_ruby_patch_level" ]] ; then rvm_ruby_patch_level="$(__rvm_db "ruby_${rvm_ruby_version/ /}_patch_level")" ; fi
- if [[ -z "$rvm_ruby_patch_level" ]] ; then unset rvm_ruby_patch_level ; fi
+ rvm_ruby_repo_url="${rvm_ruby_repo_url:-"$(__rvm_db "ruby_repo_url")"}"
if [[ -z "$rvm_ruby_version" ]] ; then __rvm_log "fail" "Unknown ruby version: $rvm_ruby_version" ; fi
;;
default|system|current|user)
#no-op?
@@ -115,23 +106,18 @@
else
__rvm_log "fail" "Ruby implementation '$rvm_ruby_interpreter' is not known."
fi
esac
- if [[ ! -z "$rvm_ruby_revision" ]] ; then
- if [[ "head" = "$rvm_ruby_revision" ]] || [[ "trunk" = "$rvm_ruby_revision" ]] ; then
- rvm_ruby_patch_level="head"
- else
- rvm_ruby_patch_level="$rvm_ruby_revision"
- fi
- fi
-
__rvm_gems_select
- if [[ ! -z "$rvm_ruby_interpreter" ]] && [[ ! -z "$rvm_ruby_version" ]] && [[ "system" != "$rvm_ruby_interpreter" ]] ; then
- rvm_major_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $2 }')
- rvm_minor_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $3 }')
+ if [[ ! -z "$rvm_ruby_interpreter" ]] && [[ "system" != "$rvm_ruby_interpreter" ]] ; then
+ if [[ ! -z "$rvm_ruby_version" ]] ; then
+ rvm_major_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $2 }')
+ rvm_minor_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $3 }')
+ fi
+
rvm_ruby_package_name="$rvm_ruby_string"
rvm_ruby_home="$rvm_path/$rvm_ruby_string"
rvm_ruby_log_path="$rvm_log_path/$rvm_ruby_string"
rvm_ruby_src_path="$rvm_src_path/$rvm_ruby_string"
rvm_ruby_binary="$rvm_ruby_home/bin/ruby"
@@ -239,114 +225,90 @@
if [[ ! -z "$rvm_load_flag" ]] ; then __rvm_gems_load ; fi
if [[ ! -z "$rvm_dump_flag" ]] ; then __rvm_gems_dump ; fi
}
__rvm_ruby_string() {
- if [[ ! -z "$rvm_ruby_string" ]] ; then
- if [[ "system" = "$rvm_ruby_string" ]] ; then
- __rvm_unset_ruby_variables
- rvm_ruby_interpreter="system"
- else
- ruby_string="${rvm_ruby_string/ruby-enterprise/ree}"
+ # rvm_ruby_string may designate any of the following items:
+ # * rvm_gem_set_name
+ # * rvm_ruby_interpreter
+ # * rvm_ruby_version
+ # * rvm_ruby_patch_level
+ # * rvm_ruby_revision
+ # * rvm_ruby_tag
- __rvm_unset_ruby_variables
+ set_name=$(echo "$rvm_ruby_string" | awk -F'%' '{print $2}')
+ if [[ ! -z "$set_name" ]] ; then rvm_gem_set_name="$set_name" ; fi
+ ruby_string=$(echo "$rvm_ruby_string" | awk -F'%' '{print $1}')
- if [[ ! -z "$(echo "$ruby_string" | awk -F'%' '{print $2}')" ]] ; then
- rvm_gem_set_name=$(echo "$ruby_string" | awk -F'%' '{print $2}')
- fi
+ __rvm_unset_ruby_variables
- ruby_string=$(echo "$ruby_string" | awk -F'%' '{print $1}')
- rvm_ruby_interpreter=$(echo $ruby_string | awk -F'-' '{print $1}')
- rvm_ruby_version=$(echo $ruby_string | awk -F'-' '{print $2}')
-
- if [[ "$rvm_ruby_version" != "head" ]] ; then
- patch_level=$(echo $ruby_string | awk -F'-' '{print $3}')
- if [[ ! -z "$patch_level" ]] ; then rvm_ruby_patch_level="p$patch_level" ; fi
+ for string in $(echo $ruby_string | tr '-' ' ') ; do
+ if [[ "head" = "$string" ]] ; then
+ rvm_ruby_revision="head"
+ unset rvm_ruby_patch_level rvm_ruby_revision rvm_ruby_tag
+ rvm_head_flag=1
+ elif [[ "system" = "$string" ]] ; then
+ break
+ elif match "$string" "^preview" ; then
+ rvm_ruby_patch_level="$string"
+ elif match "$string" "^[a-z][a-z]" ; then
+ rvm_ruby_interpreter="$string"
+ elif match "$string" "^[0-9]\.[0-9]" ; then
+ if [[ "1.8" = "$string" ]] ; then string="1.8.6" ; fi
+ if [[ "1.9" = "$string" ]] ; then string="1.9.1" ; fi
+ rvm_ruby_version="$string"
+ unset rvm_ruby_revision rvm_ruby_tag
+ elif match "$string" "^p[0-9]" ; then
+ rvm_ruby_patch_level="$string"
+ elif match "$string" "^[0-9][0-9]" ; then
+ if [[ "ree" = "$rvm_ruby_interpreter" ]] ; then
+ rvm_ruby_patch_level="$string"
+ unset rvm_ruby_revision
else
- unset rvm_ruby_version
- rvm_head_flag=1
- rvm_ruby_revision="head"
- rvm_ruby_patch_level="head"
+ rvm_ruby_revision="r$string"
fi
+ elif match "$string" "^r[0-9]" ; then
+ unset rvm_ruby_patch_level
+ rvm_ruby_revision="$string"
+ elif match "$string" "^t[0-9]" ; then
+ unset rvm_ruby_patch_level rvm_ruby_revision
+ rvm_ruby_tag="$string"
+ else
+ __rvm_log "error" "Unknown ruby string component: '$string'"
+ fi
+ done
- if match "$rvm_ruby_interpreter" "^1\.[8-9]" ; then
- rvm_ruby_patch_level=$rvm_ruby_version
- rvm_ruby_version=$rvm_ruby_interpreter
- rvm_ruby_interpreter="ruby"
- if [[ -z "$rvm_ruby_patch_level" ]] ; then
- if [[ "$rvm_ruby_version" != "head" ]] ; then
- rvm_ruby_patch_level="p$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_patch_level")"
- else
- unset rvm_ruby_version
- rvm_head_flag=1
- rvm_ruby_revision="head"
- rvm_ruby_patch_level="head"
- fi
- fi
- elif match "$rvm_ruby_interpreter" "^1\.[3-4]" ; then
- rvm_ruby_version=$rvm_ruby_interpreter
- rvm_ruby_interpreter=jruby
- unset rvm_ruby_patch_level
- fi
+ # Unspecified interpreter
+ if [[ -z "$rvm_ruby_interpreter" ]] ; then
+ if match "$rvm_ruby_version" "^1\.[8-9]" ; then
+ rvm_ruby_interpreter="ruby"
+ elif match "$rvm_ruby_version" "^0.5" ; then
+ rvm_ruby_interpreter="macruby"
+ elif match "$rvm_ruby_version" "^1.[2-4]" ; then
+ rvm_ruby_interpreter="jruby"
+ fi
+ fi
- if match "$rvm_ruby_patch_level" "^r" ; then
- rvm_ruby_revision=$rvm_ruby_patch_level
- unset rvm_ruby_patch_level
- fi
+ # Unspecified version
+ if [[ -z "$rvm_ruby_version" ]] ; then
+ rvm_ruby_version=${rvm_ruby_version:-"$(__rvm_db "${rvm_ruby_interpreter}_version")"}
+ fi
+ rvm_ruby_string="${rvm_ruby_interpreter}-${rvm_ruby_version}"
- if [[ "head" = "$rvm_ruby_version" ]] || [[ "head" = "$rvm_ruby_patch_level" ]] || [[ 1 = "$rvm_head_flag" ]] ; then
- rvm_ruby_patch_level="head"
- rvm_head_flag=1
- if [[ "rbx" = "$rvm_ruby_interpreter" ]] ; then unset rvm_ruby_patch_level ; fi
- if [[ "mput" = "$rvm_ruby_interpreter" ]] ; then unset rvm_ruby_patch_level ; fi
- else
- revision=$(echo $ruby_string | awk -F'-' '{print $NF}')
- if [[ ! -z "$revision" ]] ; then rvm_ruby_patch_level="${rvm_ruby_patch_level:-p${patch_level}}" ; fi
- if [[ ! -z "$revision" ]] ; then
- if match "$revision" "^[0-9]\.[0-9]" ; then
- unset rvm_ruby_revision rvm_ruby_tag
- elif match "$revision" "^p" ; then
- rvm_ruby_patch_level="$revision"
- # if [[ "preview" == "$revision" ]] ; then
- elif match "$revision" "^[0-9]" ; then
- if [[ "ree" = "$rvm_ruby_interpreter" ]] ; then
- rvm_ruby_patch_level="$revision"
- unset rvm_ruby_revision
- else
- rvm_ruby_revision="r$revision"
- fi
- elif match "$revision" "^r" ; then
- unset rvm_ruby_patch_level
- rvm_ruby_revision="$revision"
- elif match "$revision" "^t" ; then
- unset rvm_ruby_patch_level rvm_ruby_revision
- rvm_ruby_tag="$revision"
- else
- unset rvm_ruby_patch_level rvm_ruby_revision rvm_ruby_tag
- fi ; unset revision
- else
- patch_level="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_patch_level")"
- if [[ ! -z "$patch_level" ]] ; then
- rvm_ruby_patch_level="p$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_patch_level")"
- else
- unset rvm_ruby_patch_level
- fi ; unset patch_level
- fi
- fi
-
- if [[ ! -z "$rvm_ruby_revision" ]] ; then
- rvm_ruby_string="$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_revision"
- elif [[ ! -z "$rvm_ruby_patch_level" ]] ; then
- if match "$rvm_ruby_patch_level" "^[0-9]" ; then
- rvm_ruby_patch_level="p$rvm_ruby_patch_level"
- fi
- rvm_ruby_patch_level="$(echo $rvm_ruby_patch_level | sed 's#^pp#p#')" # sanity check, thanks sfpyra
- rvm_ruby_string="$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"
- else
- rvm_ruby_string="$rvm_ruby_interpreter-$rvm_ruby_version"
- fi
-
- unset ruby_string
+ # Unspecified patch level
+ if [[ "$rvm_head_flag" -eq 1 ]] ; then
+ rvm_ruby_string="${rvm_ruby_string}-head"
+ elif [[ ! -z "$rvm_ruby_revision" ]] ; then
+ rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_revision}"
+ elif [[ ! -z "$rvm_ruby_tag" ]] ; then
+ rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_tag}"
+ elif [[ ! -z "$rvm_ruby_patch_level" ]] ; then
+ rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_patch_level}"
+ else
+ patch_level="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_patch_level")"
+ if [[ ! -z "$patch_level" ]] ; then rvm_ruby_patch_level="p${patch_level}" ; fi
+ if [[ ! -z "$rvm_ruby_patch_level" ]] ; then
+ rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_patch_level}"
fi
fi
- return 0
}
+