scripts/rvm-selector in wayneeseguin-rvm-0.0.37 vs scripts/rvm-selector in wayneeseguin-rvm-0.0.38
- old
+ new
@@ -1,10 +1,12 @@
#!/bin/bash
# __rvm_select implementation version patch_level
function __rvm_select {
+ __rvm_ruby_string
+
rvm_ruby_interpreter="${1:-$rvm_ruby_interpreter}"
rvm_ruby_interpreter="${rvm_ruby_interpreter:-ruby}" # Default is standard ruby
temp=$(echo $rvm_ruby_interpreter | awk '{print substr($1, 0, 1)}')
if [ ! -z "$(echo $temp | grep '[0-9]')" ] ; then
@@ -101,56 +103,15 @@
rm -rf $rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name/
if [ "$rvm_gem_set_name_rm" = "$rvm_gem_set_name" ] ; then unset rvm_gem_set_name ; fi
else
rvm_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name"
fi
+ fi
- if [ ! -z "$rvm_load" ] ; then
- # TODO: Load a .gemset file.
- echo "Loading $rvm_load_file file... (not :)"
- cat $rvm_load_file | $(
- while read line ; do # for line in `cat $rvm_load_file` ; do
- if [ -z "`echo $line | sed 's/ //g' | grep '^#'`" ] ; then # Skip comment lines
- gem=`echo $line | awk -F';' '{print $1}'`
- prefix=`echo $line | awk -F';' '{print $2}'`
- if [ -z "$vars" ] ; then
- GEM_HOME="$rvm_gem_home" gem install --no-rdoc --no-ri -q $gem
- else
- eval "GEM_HOME='$rvm_gem_home' $prefix gem install --no-rdoc --no-ri -q $gem"
- fi
- unset gem prefix
- fi
- done
- )
- fi
+ if [ ! -z "$rvm_load" ] ; then __rvm_gemset_load ; fi
+ if [ ! -z "$rvm_dump" ] ; then __rvm_gemset_dump ; fi
- if [ ! -z "$rvm_dump" ] ; then
- if [ -z "$rvm_gem_set_name" ] ; then
- file_name="default"
- else
- file_name="$rvm_gem_set_name"
- fi
-
- echo "# $rvm_gem_set_name.gemset generated gem dump file. Note that any env variable settings will be missing. Append these after using a ';' field separator" > $rvm_gem_set_name.gemset
-
- gems="`gem list | sed 's/[\(|\)]//g' | sed 's/, /,/g' | tr ' ' ';'`"
- for gem in $gems ; do
- name=`echo $gem | awk -F';' '{print $1}'`
- if [ -z "$rvm_gem_latest" ] ; then
- versions=`echo $gem | awk -F';' '{print $2}' | sed 's/,/ /g'`
- for version in $versions ; do
- echo "$name -v$version" >> $file_name.gemset
- done
- unset version
- else
- echo "$name" >> $file_name.gemset
- fi
- unset name
- done
- unset file_name gems versions
- fi
- fi
mkdir -p $rvm_gem_home
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"}"
@@ -160,13 +121,14 @@
fi
rvm_ruby_log_path="$rvm_log_path/$rvm_ruby_package_name"
rvm_ruby_src_path="$rvm_source_path/$rvm_ruby_package_name"
rvm_ruby_binary="$rvm_ruby_home/bin/ruby"
rvm_ruby_irbrc="$rvm_ruby_home/.irbrc"
+ rvm_ruby_string="$rvm_ruby_package_name"
rvm_selected=1
- export rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_version rvm_ruby_package_name rvm_url rvm_ruby_patch_level rvm_ruby_configure rvm_ruby_make rvm_ruby_make_install rvm_ruby_rev rvm_ruby_tag rvm_major_version rvm_minor_version rvm_gem_set_name rvm_gem_path rvm_gem_home rvm_path rvm_source_path rvm_bin_path rvm_ruby_binary rvm_ruby_package_name rvm_ruby_home rvm_log_path rvm_ruby_log_path rvm_source_path rvm_ruby_src_path rvm_ruby_irbrc rvm_selected
+ export rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_version rvm_ruby_package_name rvm_url rvm_ruby_patch_level rvm_ruby_configure rvm_ruby_make rvm_ruby_make_install rvm_ruby_rev rvm_ruby_tag rvm_major_version rvm_minor_version rvm_gem_set_name rvm_gem_path rvm_gem_home rvm_path rvm_source_path rvm_bin_path rvm_ruby_binary rvm_ruby_package_name rvm_ruby_home rvm_log_path rvm_ruby_log_path rvm_source_path rvm_ruby_src_path rvm_ruby_irbrc rvm_selected rvm_ruby_string
else
rvm_gem_home=$GEM_HOME
fi
@@ -181,68 +143,51 @@
if [ -s $rvm_path/default ] ; then
source $rvm_path/default
else
__rvm_log "error" "no default rvm specified, defaulting to pre-rvm sytem."
- unset GEM_HOME MY_RUBY_HOME IRBRC
- PATH="$rvm_default_path" ; export PATH
- if [ -s $rvm_path/system ] ; then
- source $rvm_path/system
- fi
+ unset GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC
+ PATH="$rvm_system_path" ; export PATH
+ if [ -s $rvm_path/system ] ; then source $rvm_path/system ; fi
fi
elif [ "$rvm_ruby_interpreter" = "system" ] ; then
- unset GEM_HOME MY_RUBY_HOME IRBRC
- PATH="$rvm_default_path" ; export PATH
- if [ -s $rvm_path/system ] ; then
- source $rvm_path/system
- fi
+ unset GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC
+ PATH="$rvm_system_path" ; export PATH
+ if [ -s $rvm_path/system ] ; then source $rvm_path/system ; fi
else
GEM_HOME=$rvm_gem_home ; export GEM_HOME
+ GEM_PATH=$rvm_gem_home ; export GEM_PATH
MY_RUBY_HOME=$rvm_ruby_home ; export MY_RUBY_HOME
IRBRC="$rvm_ruby_irbrc" ; export IRBRC
if [ -z "$IRBRC" ] ; then unset IRBRC ; fi
# Install if not installed
if [ ! -d $MY_RUBY_HOME ] ; then
__rvm_log "warn" "$rvm_ruby_interpreter $rvm_ruby_version is not installed."
- __rvm_install-ruby $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level
- fi
-
- if [ ! -s "$rvm_ruby_irbrc" ] ; then
- rvm_irbrc_file=`cat <<Config
- ; # No, this is not a stray ';' :)
- require "irb/completion" rescue nil
- @prompt = {
- :PROMPT_I => "${rvm_ruby_package_name} > ", # default prompt
- :PROMPT_S => "${rvm_ruby_package_name}%l> ", # known continuation
- :PROMPT_C => "${rvm_ruby_package_name} > ",
- :PROMPT_N => "${rvm_ruby_package_name} ?> ", # unknown continuation
- :RETURN => " => %s \n",
- :AUTO_INDENT => true
- }
- @prompt_mode = :DEFAULT
- IRB.conf[:PROMPT][@prompt_mode] = @prompt
- IRB.conf[:PROMPT_MODE] = @prompt_mode
-Config
-`
- if [ -s ~/.irbrc ] ; then
- cp ~/.irbrc $rvm_ruby_home/.irbrc
+ echo -n -e "Would you like rvm to install $rvm_ruby_interpreter $rvm_ruby_version for you now?\n(Y/n) ? "
+ read response
+ if [ "$response" = 'n' ] ; then
+ __rvm_log "warn" "Please run 'rvm install $rvm_ruby_interpreter $rvm_ruby_version' if you wish to use it.\n"
+ return 0
+ else
+ __rvm_install-ruby $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level
fi
- touch $rvm_ruby_home/.irbrc
- echo "$rvm_irbrc_file" >> $rvm_ruby_home/.irbrc
fi
- PATH="$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_path/bin:$rvm_default_path" ; export PATH
+ __rvm_irbrc
+
+ PATH="$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_path/bin:$rvm_system_path" ; export PATH
+
if [ ! -z "$rvm_set_default" ] ; then
RUBY_VERSION="$($MY_RUBY_HOME/bin/ruby -v | sed 's/^\(.*\) (.*$/\1/')"
- export GEM_HOME MY_RUBY_HOME RUBY_VERSION
+ export GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION
echo "PATH=$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_path/bin:\$PATH ; export PATH" > $rvm_path/default
- for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME IRBRC ; do
+ for variable in RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC ; do
eval "export $variable"
eval value=\$${variable}
if [ ! -z "$variable" ] ; then
echo "${variable}='$value' ; export ${variable}" >> $rvm_path/default
else