bash/rvm in rvm-0.0.9 vs bash/rvm in rvm-0.0.10

- old
+ new

@@ -1,11 +1,11 @@ #!/bin/bash rvm_author="Wayne E. Seguin" rvm_author_email="wayneeseguin@gmail.com" rvm_website="http://github.com/wayneeseguin/rvm" -rvm_version="0.0.9" +rvm_version="0.0.10" rvm_updated="2009.08.25" # # License: See LICENSE # @@ -362,15 +362,13 @@ case "$implementation" in default) # TODO: There is a reproducible bug here when switching off of 1.8.7... # Seems that the path is not reset properly. - rm -f ~/.rvm/current - unset MY_RUBY_HOME - unset GEM_HOME - unset RUBY_VERSION - PATH=$original_path ; export PATH + rm -f $install_path/current + source $install_path/default + PATH="$default_path" ; export PATH ;; #leopard) MY_RUBY_HOME="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr"; GEM_HOME="$HOME/.gem/ruby/1.8" ;; jruby) version="${version-1.3.1}" @@ -433,19 +431,16 @@ fi RUBY_VERSION="$($MY_RUBY_HOME/bin/ruby -v | sed 's/^\(.*\) (.*$/\1/')" export GEM_HOME MY_RUBY_HOME RUBY_VERSION - # Setup ~/.rvm/current - echo "PATH=$MY_RUBY_HOME/bin:$GEM_HOME/bin:\$PATH ; export PATH" > ~/.rvm/current + echo "PATH=$MY_RUBY_HOME/bin:$GEM_HOME/bin:$default_path ; export PATH" > $install_path/current for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do eval "export $variable" eval value=\$${variable} - echo "${variable}='$value' ; export ${variable}" >> ~/.rvm/current + echo "${variable}='$value' ; export ${variable}" >> $install_path/current done - else - PATH=$original_path ; export PATH fi info "Switching to $implementation $version $patchlevel ..." if [ ! -z "$BASH_VERSION" ] ; then exec bash -l @@ -456,17 +451,17 @@ fi } function rvm-list { echo -e "\nruby:" - ls -l ~/.rvm/ | awk '/ ruby-[1-2].*/ { print " - " $NF }' + ls -l $install_path/ | awk '/ ruby-[1-2].*/ { print " - " $NF }' echo echo "jruby:" - ls -l ~/.rvm/ | awk '/jruby-.*/ { print " - " $NF }' + ls -l $install_path/ | awk '/jruby-.*/ { print " - " $NF }' echo echo "ree:" - ls ~/.rvm/ | awk '/ruby-enterprise-.*/ { print " - " $NF }' + ls $install_path/ | awk '/ruby-enterprise-.*/ { print " - " $NF }' echo } function rvm-gem-dir { @@ -485,10 +480,13 @@ else fail "Unknown Version: ${2-version}" fi ;; + default) + warn "Not Implemented Yet." + ;; *) fail "Ruby implementation '$implementation' is not known." esac if [ -d $GEM_HOME ] ; then @@ -498,48 +496,52 @@ fi } function rvm-src-dir { - case "$implementation" in + case "${1-implementation}" in jruby) - version="${version-1.3.1}" - if [ "$version" = "1.2.0" -o "$version" = "1.3.1" ] ; then + version=${version-1.3.1} + if [ "${2-version}" = "1.2.0" -o "${2-version}" = "1.3.1" ] ; then src_dir="$source_path/$implementation-$version" else fail "Unknown jRuby version: $version" fi ;; ree) version=${version-1.8.6} - if [ "$version" = "1.8.6" ] ; then - src_dir="$source_path/ruby-enterprise-$version-"${3-20090610}"" + if [ "${2-version}" = "1.8.6" -o "${2-version}" = "1.8" ] ; then + src_dir="$source_path/ruby-enterprise-${2-version}-"${3-20090610}"" else - fail "Unknown Ruby Enterprise Edition version: $version" + fail "Unknown Ruby Enterprise Edition version: ${2-version}" fi ;; ruby) - if [ "$version" = "1.8.7" ] ; then + if [ "${2-version}" = "1.8.7" ] ; then src_dir="$source_path/ruby-1.8.7-p${patchlevel-174}" - elif [ "${version%\.*}" = "1.8" ] ; then + elif [ "${2-version}" = "1.8" -o "${2-version}" = "1.8.6" ] ; then src_dir="$source_path/ruby-1.8.6-p${patchlevel-369}" - elif [ "$version" = "1.9.2" ] ; then + elif [ "${2-version}" = "1.9.2" ] ; then src_dir="$source_path/ruby-1.9.2-p${patchlevel-review1}" - elif [ "${version%\.*}" = "1.9" ] ; then + elif [ "${2-version}" = "1.9" -o "${2-version}" = "1.9.1" ] ; then src_dir="$source_path/ruby-1.9.1-p${patchlevel-243}" else - fail "Unknown ruby version: $version" + fail "unknown Ruby version: ${2-version}" fi ;; + default) + warn "Invalid request, rvm cannot change to the default source directory." + ;; + *) fail "Ruby implementation '$implementation' is not known." return 1 esac @@ -583,13 +585,17 @@ token="$1" ; shift case "$token" in install|uninstall|use|path|info|gemdir|setup|version|debug|srcdir|list) action=$token ;; ruby|jruby|ree|default|all) - implementation="$token" ;; + implementation="$token" + action="${action-use}" + ;; 1.8|1.8.6|1.8.7|1.9|1.9.1|1.9.2|1.2.0|1.3.1) - version="$token" ;; + version="$token" + action="${action-use}" + ;; -v|--version) if [ -z "$1" ] ; then action="version" else version="$1" @@ -619,21 +625,28 @@ fail "root user support is not yet implemented." #prefix_path=${prefix-/usr/local/} else prefix_path=${prefix-$HOME/.} fi - source_path="${source_path-${prefix_path}rvm/src}" + source_path="${source_path-$install_path/src}" install_path="${prefix_path}rvm" - mkdir -p ~/.rvm/ $source_path $install_path + mkdir -p $prefix_path $source_path $install_path - if [ -f ~/.rvm/original_path ] ; then - original_path=`cat ~/.rvm/original_path` + if [ ! -f $install_path/default ] ; then + for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME PATH ; do + eval "export $variable" + eval value=\$${variable} + echo "${variable}='$value' ; export ${variable}" >> $install_path/default + done fi - if [ -z "$original_path" ] ; then - echo $PATH > $install_path/.original_path - original_path=$PATH + + if [ -s $install_path/default_path ] ; then + default_path=`cat $install_path/default_path` + else + echo $PATH > $install_path/default_path + default_path=$PATH fi if [ "$debug" = "1" ] ; then set -x ; fi case "$action" in @@ -664,10 +677,10 @@ rvm-version info "GEM_HOME: $GEM_HOME\nMY_RUBY_HOME: $MY_RUBY_HOME" info "ruby: `which ruby`\ngem: `which gem`\nirb: `which irb`" info "PATH:$(echo $PATH | awk -F":" '{print $1":"$2":"$3":"$4":"%5}')" info "\n.bash_profile: \n$(cat ~/.bash_profile | tail -n 5)\n" - info "\n.rvm/current: \n$(cat ~/.rvm/current)\n" + info "\n$install_path/current: \n$($install_path/current)\n" return 0 ;; *) if [ ! -z "$action" ] ; then fail "unknown action '$action'"