scripts/rvm-utility in wayneeseguin-rvm-0.0.36 vs scripts/rvm-utility in wayneeseguin-rvm-0.0.37

- old
+ new

@@ -2,12 +2,12 @@ function __rvm_meta { rvm_meta_author="Wayne E. Seguin" rvm_meta_author_email="wayneeseguin@gmail.com" rvm_meta_website="http://rvm.beginrescueend.com/" - rvm_meta_version="0.0.36" - rvm_meta_updated="2009.09.06" + rvm_meta_version="0.0.37" + rvm_meta_updated="2009.09.09" } function __rvm_version { __rvm_meta ; echo "rvm $rvm_meta_version ($rvm_meta_updated) [$rvm_meta_website]" ; } function __rvm_usage { @@ -35,10 +35,11 @@ install - Install a ruby version, default is from source uninstall - Uninstall a ruby version reset - Remove default and current settings, exit the shell. (If you experience odd behavior try this first) rubydo - Used with -f to run a ruby file against specified or all rubies + gemdo - Used with -f to execute a command using selected ruby's 'gem' debug - Emit environment & configuration information for *current* ruby reload - Reload rvm source itself (useful after changing rvm source) implode - Removes all ruby installations it manages, everything in ~/.rvm update - Upgrades rvm to the latest version. @@ -116,28 +117,33 @@ binaries: ruby: "`which ruby`" irb: "`which irb`" gem: "`which gem`" + rake: "`which rake`" environment: GEM_HOME: "$GEM_HOME" MY_RUBY_HOME: "$MY_RUBY_HOME" IRBRC: "$IRBRC" Info } function __rvm_debug { + __rvm_log "info" "PATH:$(echo $PATH | awk -F":" '{print $1":"$2":"$3":"$4":"$5}')" + for file in .bash_profile .bashrc .zshrc ; do if [ -s $file ] ; then __rvm_log "debug" "~/$file:\n$(grep rvm ~/$file)\n" fi done - if [ -s $rvm_path/current ] ; then - __rvm_log "debug" "$rvm_path/current:\n$($rvm_path/current)\n" + + if [ -s $rvm_path/default ] ; then + __rvm_log "debug" "$rvm_path/default:\n$($rvm_path/default)\n" fi + if [ -e $rvm_path/bin/rvm ] ; then __rvm_log "debug" "rvm script in bin:\n$(ls -laht $rvm_path/bin/rvm)" fi } @@ -176,11 +182,11 @@ if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/$log_file_name.error.log" ; popd 2> /dev/null ; return 1 ; fi unset log_file command } function __rvm_cleanup-variables { - unset rvm_selected rvm_action rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_irbrc_file rvm_ruby_irbrc rvm_source_path rvm_path rvm_debug rvm_prefix_path rvm_ruby_package_name rvm_gem_path rvm_command rvm_error_message rvm_ruby_home rvm_ruby_binary rvm_gem_set_name rvm_delete_flag rvm_ruby_tag rvm_ruby_rev rvm_url rvm_ruby_make rvm_ruby_make_install rvm_config_path rvm_bin_path rvm_force rvm_set_prompt rvm_all rvm_re_configure + unset rvm_selected rvm_action rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_irbrc_file rvm_ruby_irbrc rvm_source_path rvm_path rvm_debug rvm_prefix_path rvm_ruby_package_name rvm_gem_path rvm_command rvm_error_message rvm_ruby_home rvm_ruby_binary rvm_gem_set_name rvm_delete_flag rvm_ruby_tag rvm_ruby_rev rvm_url rvm_ruby_make rvm_ruby_make_install rvm_config_path rvm_bin_path rvm_force rvm_all rvm_re_configure } # TODO: root user loadng of /etc/rvmrc function __rvm_load-rvmrc { if [ -s ~/.rvmrc ] ; then source ~/.rvmrc ; fi @@ -189,10 +195,11 @@ function __rvm_bin_scripts { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi ruby_wrapper=$(cat <<-RubyWrapper #!/bin/bash +puts "rvm installed ruby binaries should *not* be run as the root user (yet): http://rvm.beginrescueend.com/faq/" if (`whoami`.strip == "root") GEM_HOME=$rvm_gem_home ; export GEM_HOME MY_RUBY_HOME=$rvm_ruby_home ; export MY_RUBY_HOME PATH=$rvm_ruby_home/bin:$rvm_gem_home/bin:\$PATH ; export PATH exec "$rvm_ruby_binary" "\$@" @@ -203,11 +210,10 @@ unset ruby_wrapper chmod +x $rvm_bin_path/$rvm_ruby_package_name } - function __rvm_fetch { pushd $rvm_archives_path > /dev/null eval $rvm_fetch "$1" if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi @@ -215,19 +221,19 @@ } function __rvm_load-defaults { - if [ ! -s $rvm_path/default ] ; then - for variable in rvm_prompt RUBY_VERSION GEM_HOME MY_RUBY_HOME PATH ; do + if [ ! -s $rvm_path/system ] ; then + for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME PATH ; do eval value=\$${variable} if [ -z "$value" ] ; then - echo "unset ${variable}" >> $rvm_path/default + echo "unset ${variable}" >> $rvm_path/system else eval "export $variable" eval value=\$${variable} - echo "${variable}='$value' ; export ${variable}" >> $rvm_path/default + echo "${variable}='$value' ; export ${variable}" >> $rvm_path/system fi done fi rvm_default_path=`__rvm_db "rvm_default_path"` @@ -269,13 +275,15 @@ } function __rvm_reset { PATH="$rvm_path/bin:$rvm_default_path" ; export PATH - for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME rvm_prompt ; do unset $variable ; done + for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do unset $variable ; done + if [ -f $rvm_path/system ] ; then rm -f $rvm_path/system ; fi rm -f $rvm_path/default* - rm -f $rvm_path/current + # TODO: Remove this after a few releases: + rm -f $rvm_path/current* __rvm_select "system" for default in default_ps1 default_path default_system_ruby default_system_gem_path default_user_gem_path ; do __rvm_db "$default" "delete" @@ -320,11 +328,11 @@ echo "$rvm_ruby_src_path" fi } -# clones from source implementation/version to current +# clones from source implementation/version to default function __rvm_gem-dup { if [ "$1" = "default" ] ; then rvm_source_gem_dir="$rvm_default_user_gem_path" elif [ "$1" = "system" ] ; then @@ -402,27 +410,63 @@ echo "rubinius head" echo "rbx head" echo "rbx head --jit" echo "ree 20090610" else - echo -e "\nruby:\n$(/bin/ls -l $rvm_path/ | awk '/ ruby-[1-2].*/ { print " - " $NF }')\n" - echo -e "jruby:\n$(/bin/ls -l $rvm_path/ | awk '/jruby-.*/ { print " - " $NF }')\n" - echo -e "ree:\n$(/bin/ls $rvm_path/ | awk '/ruby-enterprise-.*/ { print " - " $NF }')\n" - echo -e "system:\n - ($($rvm_default_system_ruby -v))\n" + current=`which ruby | xargs dirname | xargs dirname | xargs basename` + echo -e "\nruby:\n" + for version in `/bin/ls -l $rvm_path/ | awk '/ ruby-[1-2].*/ { print $NF }'` ; do + if [ "$current" = "$version" ] ; then + echo -e "=> $version" + selected="1" + else + echo -e " $version" + fi + done + unset version + + echo -e "\njruby:\n" + for version in `/bin/ls -l $rvm_path/ | awk '/jruby-.*/ { print $NF }'` ; do + if [ "$current" = "$version" ] ; then + echo -e "=> $version" + selected="1" + else + echo -e " $version" + fi + done + unset version + + echo -e "\nree:\n" + for version in `/bin/ls $rvm_path/ | awk '/ruby-enterprise-.*/ { print $NF }'` ; do + if [ "$current" = "$version" ] ; then + echo -e "=> $version" + selected="1" + else + echo -e " $version" + fi + done + + echo -e "\nsystem:\n" + if [ "$selected" = "1" ] ; then + echo -e " $($rvm_default_system_ruby -v)\n" + else + echo -e "=> $($rvm_default_system_ruby -v)\n" + fi + unset current version selected fi } function __rvm_initialize { rvm_fetch=`which curl` if [ $? -ne 0 ] ; then rvm_fetch=`which wget` if [ $? -ne 0 ] ; then - rvm_fetch="wget -q -c " - else __rvm_log "fail" "rvm expects either curl or wget, neither seem to be in your path :(" + else + rvm_fetch="wget -q -c " fi else rvm_fetch="$rvm_fetch -O -L -s --create-dirs -C - " fi @@ -460,7 +504,6 @@ PATH=$rvm_bin_path:$PATH ; export PATH fi mkdir -p $rvm_source_path $rvm_bin_path $rvm_archives_path } -