scripts/selector in rvm-0.0.62 vs scripts/selector in rvm-0.0.63
- old
+ new
@@ -1,32 +1,16 @@
#!/bin/bash
# __rvm_select implementation version patch_level
function __rvm_select {
- if [[ ! -z "$rvm_ruby_string" ]] ; then
- if [[ ! -z "$(echo "$rvm_ruby_string" | awk '/^.+%.+$/')" ]] ; then
- rvm_gem_set_name="$(echo "$rvm_ruby_string" | awk -F'%' '{print $2}')"
- rvm_ruby_string="$(echo "$rvm_ruby_string" | awk -F'%' '{print $1}')"
- fi
-
- if [[ ! -z "$(echo "$rvm_ruby_string" | awk '/^[0-9]/')" ]] ; then
- rvm_ruby_interpreter="${rvm_ruby_interpreter:-ruby}"
- rvm_ruby_version=$rvm_ruby_string
- else
- rvm_ruby_interpreter="$rvm_ruby_string"
- unset rvm_ruby_version
- fi
- elif [[ ! -z "$rvm_ruby_interpreter" ]] ; then
- if [[ ! -z "$(echo $rvm_ruby_interpreter | awk '/^[0-9]/')" ]] ; then
- rvm_ruby_version=$rvm_ruby_interpreter
- rvm_ruby_interpreter="ruby"
- else
- rvm_ruby_interpreter="${rvm_ruby_interpreter:-ruby}" # Default is standard ruby
- fi
+ if [[ -z "$rvm_ruby_string" ]] ; then
+ 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
-
- if [[ ! -z "$rvm_ruby_string" ]] ; then __rvm_ruby_string ; 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)
@@ -47,53 +31,75 @@
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_url=$rvm_ruby_repo_url
rvm_ruby_configure=""
rvm_ruby_make="build"
rvm_ruby_make_install=""
;;
jruby)
- rvm_ruby_version="${rvm_ruby_version:-"$(__rvm_db "jruby_version")"}"
rvm_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}"
- if [[ ! -z "$(echo $rvm_ruby_version | awk '/^1.4/')" ]] ; then
+ rvm_ruby_version="${rvm_ruby_version:-"$(__rvm_db "jruby_version")"}"
+ unset rvm_ruby_patch_level
+ if match "$rvm_ruby_version" "^1.4" ; then
rvm_ruby_version="1.4.0RC1"
+ rvm_ruby_string="jruby-1.4.0RC1"
rvm_package_file="$rvm_ruby_interpreter-bin-${rvm_ruby_version}"
else
rvm_package_file="$rvm_ruby_interpreter-bin-$rvm_ruby_version"
+ rvm_ruby_string="${rvm_ruby_interpreter}-${rvm_ruby_version}"
fi
rvm_url="http://dist.codehaus.org/$rvm_ruby_interpreter/$rvm_ruby_version/$rvm_package_file.tar.gz"
- unset rvm_ruby_patch_level
- if [[ -z "$(echo $rvm_ruby_version | awk '/^1\.[2-4]/')" ]] ; then
- __rvm_log "fail" "Unknown jRuby version: $rvm_ruby_version"
- fi
alias jruby_ng="jruby --ng"
alias jruby_ng_server="jruby --ng-server"
;;
ruby-enterprise|ree)
rvm_ruby_interpreter=ree
rvm_ruby_version=${rvm_ruby_version:-"$(__rvm_db "ree_version")"}
- if [[ "$rvm_ruby_version" != "head" ]] ; then
+ 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
+ rvm_ruby_patch_level="$(echo $rvm_ruby_patch_level | sed 's#^p##')"
fi
- rvm_ruby_package_name="ree-$rvm_ruby_version-$rvm_ruby_patch_level"
- rvm_ruby_package_file="ruby-enterprise-$rvm_ruby_version-$rvm_ruby_patch_level"
- if [[ -z "$(echo $rvm_ruby_version | awk '/^1\.8/')" ]] ; then
+ 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
;;
+ mput|shyouhei)
+ rvm_ruby_interpreter="mput"
+ rvm_ruby_version="head"
+ rvm_ruby_string="mput-head"
+ unset rvm_ruby_patch_level
+ rvm_ruby_repo_url=${rvm_mput_repo_url:-"$(__rvm_db "shyouhei_repo_url")"}
+ 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
+ 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
if [[ -z "$rvm_ruby_version" ]] ; then __rvm_log "fail" "Unknown ruby version: $rvm_ruby_version" ; fi
;;
@@ -122,30 +128,22 @@
__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_patch_level" ]] ; then
- rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_interpreter-$rvm_ruby_version"}"
- rvm_ruby_home="${rvm_ruby_home:-"$rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version"}"
- else
- if [[ "$rvm_ruby_interpreter" != "ree" ]] ; then
- if [[ ! -z "$(echo $rvm_ruby_patch_level | awk '/^[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
- fi
- rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"}"
- rvm_ruby_home="${rvm_ruby_home:-"$rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"}"
- fi
-
- rvm_ruby_string="$rvm_ruby_package_name"
- rvm_ruby_log_path="$rvm_log_path/$rvm_ruby_package_name"
+ 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"
rvm_ruby_irbrc="$rvm_ruby_home/.irbrc"
+ if [[ -z "$rvm_gem_set_name" ]] ; then
+ rvm_ruby_gem_home="${rvm_gem_path}/${rvm_ruby_interpreter}/${rvm_ruby_version}"
+ else
+ rvm_ruby_gem_home="${rvm_gem_path}/${rvm_ruby_interpreter}/${rvm_ruby_version}%${rvm_gem_set_name}"
+ fi
+
rvm_ruby_selected_flag=1
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_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_major_version rvm_minor_version rvm_gem_set_name rvm_gem_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_gem_home="$GEM_HOME"
@@ -186,11 +184,11 @@
else
GEM_HOME=$rvm_ruby_gem_home ; export GEM_HOME
GEM_PATH=$rvm_ruby_gem_home ; export GEM_PATH
MY_RUBY_HOME=$rvm_ruby_home ; export MY_RUBY_HOME
- RUBY_VERSION=$rvm_ruby_package_name ; export RUBY_VERSION
+ RUBY_VERSION=$rvm_ruby_string ; export RUBY_VERSION
IRBRC="$rvm_ruby_irbrc" ; export IRBRC
if [[ -z "$IRBRC" ]] ; then unset IRBRC ; fi
if [[ ! -d $MY_RUBY_HOME ]] ; then
__rvm_log "warn" "$rvm_ruby_interpreter $rvm_ruby_version is not installed."
@@ -225,14 +223,14 @@
else
echo "unset ${variable}" >> $rvm_path/default
fi
done ; unset variable value
- if [[ -s $rvm_path/bin/$rvm_ruby_package_name ]] ; then
- ln -fs $rvm_path/bin/$rvm_ruby_package_name $rvm_path/bin/default-ruby # So that people know what it's for :)
- ln -fs $rvm_path/bin/gem-$rvm_ruby_package_name $rvm_path/bin/default-gem
- ln -fs $rvm_path/bin/irb-$rvm_ruby_package_name $rvm_path/bin/default-irb
+ if [[ -s "$rvm_path/bin/$rvm_ruby_string" ]] ; then
+ ln -fs "$rvm_path/bin/$rvm_ruby_string" "$rvm_path/bin/default-ruby" # So that people know what it's for :)
+ ln -fs "$rvm_path/bin/gem-$rvm_ruby_string" "$rvm_path/bin/default-gem"
+ ln -fs "$rvm_path/bin/irb-$rvm_ruby_string" "$rvm_path/bin/default-irb"
else
rm -f $rvm_path/bin/default*
fi
fi
unset rvm_default_flag
@@ -241,67 +239,109 @@
if [[ ! -z "$rvm_load_flag" ]] ; then __rvm_gems_load ; fi
if [[ ! -z "$rvm_dump_flag" ]] ; then __rvm_gems_dump ; fi
}
function __rvm_ruby_string {
- if [[ "system" = "$rvm_ruby_interpreter" ]] ; then
- rvm_ruby_string="system"
- elif [[ ! -z "$rvm_ruby_string" ]] ; then
- ruby_string=$(echo "$rvm_ruby_string" | sed 's#ruby-enterprise#ree#g') # dash-antics
- if [[ ! -z "$(echo "$rvm_ruby_string" | awk -F'%' '{print $2}')" ]] ; then
- rvm_gem_set_name=$(echo "$rvm_ruby_string" | awk -F'%' '{print $2}')
- fi
- set +x
- ruby_string=$(echo "$rvm_ruby_string" | awk -F'%' '{print $1}')
- __rvm_unset_ruby_variables
-
- 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="$patch_level" ; fi
+ if [[ ! -z "$rvm_ruby_string" ]] ; then
+ if [[ "system" = "$rvm_ruby_string" ]] ; then
+ __rvm_unset_ruby_variables
+ rvm_ruby_interpreter="system"
else
- rvm_ruby_patch_level="head"
- fi
+ ruby_string="${rvm_ruby_string/ruby-enterprise/ree}"
- if [[ ! -z "$(echo $rvm_ruby_interpreter | awk '/^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="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_patch_level")"
- else
- rvm_ruby_patch_level="head"
+ __rvm_unset_ruby_variables
+
+ if [[ ! -z "$(echo "$ruby_string" | awk -F'%' '{print $2}')" ]] ; then
+ rvm_gem_set_name=$(echo "$ruby_string" | awk -F'%' '{print $2}')
+ fi
+
+ 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="$patch_level" ; fi
+ else
+ unset rvm_ruby_version
+ rvm_head_flag=1
+ rvm_ruby_revision="head"
+ rvm_ruby_patch_level="head"
+ fi
+
+ 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
- elif [[ ! -z "$(echo $rvm_ruby_interpreter | awk '/^1\.[3-4]/')" ]] ; then
- rvm_ruby_version=$rvm_ruby_interpreter
- rvm_ruby_interpreter=jruby
- unset rvm_ruby_patch_level
- fi
- if [[ "head" = "$rvm_ruby_version" ]] ; then
- revision="head"
- if [[ "ree" = "$rvm_ruby_interpreter" ]] ; then rvm_ruby_version="1.8.7" ; fi
- if [[ "rbx" = "$rvm_ruby_interpreter" ]] ; then unset revision ; fi
- else
- revision=$(echo $ruby_string | awk -F'-' '{print $3}')
- fi
+ if match "$rvm_ruby_patch_level" "^r" ; then
+ rvm_ruby_revision=$rvm_ruby_patch_level
+ unset rvm_ruby_patch_level
+ fi
- if [[ "head" = "$revision" ]] || [[ "preview" = "$revision" ]] ; then
- rvm_ruby_revision="$revision"
- else
- if [[ ! -z "$(echo $revision | awk '/^p[0-9]\+/')" ]] ; then
- rvm_ruby_patch_level=${rvm_ruby_patch_level:-$(echo $revision | awk -F'p' '{print $2}')}
+ 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
- if [[ ! -z "$(echo $revision | awk '/^[0-9]\+/')" ]] ; then
- rvm_ruby_revision="$revision"
+ revision=$(echo $ruby_string | awk -F'-' '{print $3}')
+ if [[ ! -z "$revision" ]] ; then
+ if 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
+ rvm_ruby_revision="$revision"
+ elif match "$revision" "^t" ; then
+ rvm_ruby_tag="$revision"
+ else
+ unset rvm_ruby_patch_level rvm_ruby_revision rvm_ruby_tag
+ fi ; unset revision
else
- unset rvm_ruby_revision
+ 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
fi
- unset ruby_string
fi
return 0
}