wayneeseguin-rvm 0.0.37 → 0.0.38

Sign up to get free protection for your applications and to get access to all the features.
data/scripts/rvm-selector CHANGED
@@ -3,6 +3,8 @@
3
3
  # __rvm_select implementation version patch_level
4
4
  function __rvm_select {
5
5
 
6
+ __rvm_ruby_string
7
+
6
8
  rvm_ruby_interpreter="${1:-$rvm_ruby_interpreter}"
7
9
  rvm_ruby_interpreter="${rvm_ruby_interpreter:-ruby}" # Default is standard ruby
8
10
 
@@ -103,52 +105,11 @@ function __rvm_select {
103
105
  else
104
106
  rvm_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name"
105
107
  fi
108
+ fi
106
109
 
107
- if [ ! -z "$rvm_load" ] ; then
108
- # TODO: Load a .gemset file.
109
- echo "Loading $rvm_load_file file... (not :)"
110
- cat $rvm_load_file | $(
111
- while read line ; do # for line in `cat $rvm_load_file` ; do
112
- if [ -z "`echo $line | sed 's/ //g' | grep '^#'`" ] ; then # Skip comment lines
113
- gem=`echo $line | awk -F';' '{print $1}'`
114
- prefix=`echo $line | awk -F';' '{print $2}'`
115
- if [ -z "$vars" ] ; then
116
- GEM_HOME="$rvm_gem_home" gem install --no-rdoc --no-ri -q $gem
117
- else
118
- eval "GEM_HOME='$rvm_gem_home' $prefix gem install --no-rdoc --no-ri -q $gem"
119
- fi
120
- unset gem prefix
121
- fi
122
- done
123
- )
124
- fi
125
-
126
- if [ ! -z "$rvm_dump" ] ; then
127
- if [ -z "$rvm_gem_set_name" ] ; then
128
- file_name="default"
129
- else
130
- file_name="$rvm_gem_set_name"
131
- fi
110
+ if [ ! -z "$rvm_load" ] ; then __rvm_gemset_load ; fi
111
+ if [ ! -z "$rvm_dump" ] ; then __rvm_gemset_dump ; fi
132
112
 
133
- 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
134
-
135
- gems="`gem list | sed 's/[\(|\)]//g' | sed 's/, /,/g' | tr ' ' ';'`"
136
- for gem in $gems ; do
137
- name=`echo $gem | awk -F';' '{print $1}'`
138
- if [ -z "$rvm_gem_latest" ] ; then
139
- versions=`echo $gem | awk -F';' '{print $2}' | sed 's/,/ /g'`
140
- for version in $versions ; do
141
- echo "$name -v$version" >> $file_name.gemset
142
- done
143
- unset version
144
- else
145
- echo "$name" >> $file_name.gemset
146
- fi
147
- unset name
148
- done
149
- unset file_name gems versions
150
- fi
151
- fi
152
113
  mkdir -p $rvm_gem_home
153
114
 
154
115
  if [ -z "$rvm_ruby_patch_level" ] ; then
@@ -162,9 +123,10 @@ function __rvm_select {
162
123
  rvm_ruby_src_path="$rvm_source_path/$rvm_ruby_package_name"
163
124
  rvm_ruby_binary="$rvm_ruby_home/bin/ruby"
164
125
  rvm_ruby_irbrc="$rvm_ruby_home/.irbrc"
126
+ rvm_ruby_string="$rvm_ruby_package_name"
165
127
  rvm_selected=1
166
128
 
167
- 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
129
+ 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
168
130
 
169
131
  else
170
132
  rvm_gem_home=$GEM_HOME
@@ -183,23 +145,20 @@ function __rvm_use {
183
145
  source $rvm_path/default
184
146
  else
185
147
  __rvm_log "error" "no default rvm specified, defaulting to pre-rvm sytem."
186
- unset GEM_HOME MY_RUBY_HOME IRBRC
187
- PATH="$rvm_default_path" ; export PATH
188
- if [ -s $rvm_path/system ] ; then
189
- source $rvm_path/system
190
- fi
148
+ unset GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC
149
+ PATH="$rvm_system_path" ; export PATH
150
+ if [ -s $rvm_path/system ] ; then source $rvm_path/system ; fi
191
151
  fi
192
152
 
193
153
  elif [ "$rvm_ruby_interpreter" = "system" ] ; then
194
154
 
195
- unset GEM_HOME MY_RUBY_HOME IRBRC
196
- PATH="$rvm_default_path" ; export PATH
197
- if [ -s $rvm_path/system ] ; then
198
- source $rvm_path/system
199
- fi
155
+ unset GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC
156
+ PATH="$rvm_system_path" ; export PATH
157
+ if [ -s $rvm_path/system ] ; then source $rvm_path/system ; fi
200
158
 
201
159
  else
202
160
  GEM_HOME=$rvm_gem_home ; export GEM_HOME
161
+ GEM_PATH=$rvm_gem_home ; export GEM_PATH
203
162
  MY_RUBY_HOME=$rvm_ruby_home ; export MY_RUBY_HOME
204
163
  IRBRC="$rvm_ruby_irbrc" ; export IRBRC
205
164
  if [ -z "$IRBRC" ] ; then unset IRBRC ; fi
@@ -207,41 +166,27 @@ function __rvm_use {
207
166
  # Install if not installed
208
167
  if [ ! -d $MY_RUBY_HOME ] ; then
209
168
  __rvm_log "warn" "$rvm_ruby_interpreter $rvm_ruby_version is not installed."
210
- __rvm_install-ruby $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level
211
- fi
212
-
213
- if [ ! -s "$rvm_ruby_irbrc" ] ; then
214
- rvm_irbrc_file=`cat <<Config
215
- ; # No, this is not a stray ';' :)
216
- require "irb/completion" rescue nil
217
- @prompt = {
218
- :PROMPT_I => "${rvm_ruby_package_name} > ", # default prompt
219
- :PROMPT_S => "${rvm_ruby_package_name}%l> ", # known continuation
220
- :PROMPT_C => "${rvm_ruby_package_name} > ",
221
- :PROMPT_N => "${rvm_ruby_package_name} ?> ", # unknown continuation
222
- :RETURN => " => %s \n",
223
- :AUTO_INDENT => true
224
- }
225
- @prompt_mode = :DEFAULT
226
- IRB.conf[:PROMPT][@prompt_mode] = @prompt
227
- IRB.conf[:PROMPT_MODE] = @prompt_mode
228
- Config
229
- `
230
- if [ -s ~/.irbrc ] ; then
231
- cp ~/.irbrc $rvm_ruby_home/.irbrc
169
+ echo -n -e "Would you like rvm to install $rvm_ruby_interpreter $rvm_ruby_version for you now?\n(Y/n) ? "
170
+ read response
171
+ if [ "$response" = 'n' ] ; then
172
+ __rvm_log "warn" "Please run 'rvm install $rvm_ruby_interpreter $rvm_ruby_version' if you wish to use it.\n"
173
+ return 0
174
+ else
175
+ __rvm_install-ruby $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level
232
176
  fi
233
- touch $rvm_ruby_home/.irbrc
234
- echo "$rvm_irbrc_file" >> $rvm_ruby_home/.irbrc
235
177
  fi
236
- PATH="$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_path/bin:$rvm_default_path" ; export PATH
178
+
179
+ __rvm_irbrc
180
+
181
+ PATH="$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_path/bin:$rvm_system_path" ; export PATH
237
182
 
238
183
  if [ ! -z "$rvm_set_default" ] ; then
239
184
  RUBY_VERSION="$($MY_RUBY_HOME/bin/ruby -v | sed 's/^\(.*\) (.*$/\1/')"
240
- export GEM_HOME MY_RUBY_HOME RUBY_VERSION
185
+ export GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION
241
186
 
242
187
  echo "PATH=$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_path/bin:\$PATH ; export PATH" > $rvm_path/default
243
188
 
244
- for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME IRBRC ; do
189
+ for variable in RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC ; do
245
190
  eval "export $variable"
246
191
  eval value=\$${variable}
247
192
  if [ ! -z "$variable" ] ; then
@@ -0,0 +1,176 @@
1
+ #!/bin/bash
2
+
3
+ user=`whoami`
4
+ if [ "$user" = "root" ] ; then
5
+ echo -e "\033[0;31m <e> \033[0mroot user support is not yet implemented.\033[0m"
6
+ exit 1
7
+ fi
8
+
9
+ info="\n\033[0;32m<i>\033[0m"
10
+ question="\n\033[0;32m<?>\033[0m"
11
+ cwd=$(pwd)
12
+ source_dir="${source_dir:-`dirname $0 | xargs dirname`}"
13
+ if [ ! -d "$source_dir" ] ; then unset source_dir ; fi
14
+ source_dir="${source_dir:-$cwd}"
15
+ rvm_dir=~/.rvm
16
+
17
+ echo -e "\nInstalling rvm source to ~/.rvm/scripts/rvm..."
18
+ for dir in src scripts bin log archives config gems examples ; do
19
+ mkdir -p $rvm_dir/$dir
20
+ done
21
+
22
+ # State what is required to use rvm
23
+ echo -e "\n\033[0;32mrvm\033[0m is a shell script that allows a user to manage multiple ruby versions in their own account."
24
+ echo -e "$info In order to use rvm the following line must occur in your shell's loading files:"
25
+ echo -e "\n\033[0;32m (a)\033[0m if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi"
26
+
27
+ results=$(grep 'scripts/rvm' ~/.bash_profile ~/.bashrc ~/.zshrc > /dev/null)
28
+ if [ $? -gt 0 ] ; then
29
+ while : ; do
30
+ echo -n -e "$question Do you want this (s)cript to set this up for you, or do it (m)anually yourself ('s' or 'm')? "
31
+ read response
32
+ if [ "${response:0:1}" = "s" ] ; then
33
+ echo 'w00t!'
34
+ break
35
+ elif [ "${response:0:1}" = "m" ] ; then
36
+ echo -e "$info Please make sure that this line is in place."
37
+ break
38
+ fi
39
+ done
40
+
41
+ if [ "${response:0:1}" = "s" ] ; then
42
+
43
+ while : ; do
44
+ echo -n -e "$question Do you use b(a)sh or (z)sh or b(o)th for your shell (the default on most *nix systems is bash, press control + C to cancel the installation)\n(a/z/o)? "
45
+ read response
46
+ if [ "${response:0:1}" = "a" ] ; then
47
+ user_shell="bash"
48
+ break
49
+ elif [ "${response:0:1}" = "z" ] ; then
50
+ user_shell="zsh"
51
+ break
52
+ elif [ "${response:0:1}" = "o" ] ; then
53
+ user_shell="both"
54
+ break
55
+ fi
56
+ done
57
+
58
+ if [ "$user_shell" = "bash" -o "$user_shell" = "both" ] ; then
59
+
60
+ touch ~/.bash_profile
61
+ if [ -z "`grep '\.rvm/scripts/rvm' ~/.bash_profile`" ] ; then
62
+ echo "Adding 'if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi' to your ~/.bash_profile."
63
+ echo -e "\n" >> ~/.bash_profile
64
+ echo "if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi" >> ~/.bash_profile
65
+ fi
66
+ touch ~/.bashrc
67
+ if [ -z "`grep '\.rvm/scripts/rvm' ~/.bashrc`" ] ; then
68
+ echo "Adding 'if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi' to your ~/.bashrc."
69
+ echo -e "\n" >> ~/.bashrc
70
+ echo "if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi" >> ~/.bashrc
71
+ fi
72
+
73
+ fi
74
+
75
+ if [ "$user_shell" = "zsh" -o "$user_shell" = "both" ] ; then
76
+
77
+ touch ~/.zshrc
78
+ if [ -z "`grep '\.rvm/scripts/rvm' ~/.zshrc`" ] ; then
79
+ echo "Adding 'if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi' to your ~/.zshrc."
80
+ echo -e "\n" >> ~/.zshrc
81
+ echo "if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi" >> ~/.zshrc
82
+ fi
83
+ fi
84
+
85
+ fi
86
+ fi
87
+
88
+ echo -e "\n\033[0;32m<i>\033[0m Ensuring that rvm script location in $file is scripts/rvm not bin/rvm for: ~/.bash_profile, ~/.bashrc, ~/.zshrc"
89
+ for file in ~/.bash_profile ~/.bashrc ~/.zshrc ; do
90
+ if [ -s $file ] ; then
91
+ if [ -L $file ] ; then # If the file is a symlink,
92
+ actual_file=`readlink $file` # read the link target so we can preserve it.
93
+ else
94
+ actual_file="$file"
95
+ fi
96
+
97
+ grep 'rvm\/bin\/rvm' $actual_file > /dev/null
98
+ if [ $? -eq 0 ] ; then
99
+ sed -i.orig 's/rvm\/bin\/rvm/rvm\/scripts\/rvm/g' $actual_file
100
+ rm -f $actual_file.orig
101
+ fi
102
+
103
+ if [ -f ~/.profile ] ; then
104
+ grep '.profile' $actual_file > /dev/null
105
+ if [ $? -gt 0 ] ; then
106
+ profile=~/.profile
107
+ echo -e "\n" >> $actual_file
108
+ echo "source $profile" >> $actual_file
109
+ fi
110
+ fi
111
+ fi
112
+ done
113
+
114
+ if [ -f ~/.rvm/bin/rvm ] ; then
115
+ echo -e "\n\033[0;32m<i>\033[0m Removing old rvm file from ~/.rvm/bin/rvm"
116
+ rm -f ~/.rvm/bin/rvm
117
+ fi
118
+
119
+ for dir in config scripts examples ; do
120
+ mkdir -p $rvm_dir/$dir
121
+ for file in `/bin/ls $source_dir/$dir/`; do
122
+ cp $source_dir/$dir/$file $rvm_dir/$dir/$file
123
+ done
124
+ done
125
+ cp $source_dir/scripts/rvm-prompt $rvm_dir/bin/
126
+ cp $source_dir/VERSION.yml $rvm_dir/
127
+
128
+ system=`uname`
129
+ if [ "$system" = "Linux" ] ; then
130
+ rvm_apt_get_binary=`which apt-get 2> /dev/null`
131
+ rvm_emerge_binary=`which emerge 2> /dev/null`
132
+ rvm_pacman_binary=`which pacman 2> /dev/null`
133
+ rvm_yum_binary=`which yum 2> /dev/null`
134
+
135
+ if [ ! -z "$rvm_apt_get_binary" ] ; then
136
+ echo -e "\033[0;33m <w> \033[0mFor jRuby (if you wish to use it) you will need:"
137
+ echo -e "\033[0;32m <i> \033[0msudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk"
138
+ echo -e "\033[0;33m <w> \033[0mFor ree (if you wish to use it) you will need:"
139
+ echo -e "\033[0;32m <i> \033[0msudo apt-get install libreadline5-dev libssl-dev "
140
+
141
+ elif [ ! -z "$rvm_emerge_binary" ] ; then
142
+ echo -e "\033[0;33m <w> \033[0mFor jRuby (if you wish to use it) you will need:"
143
+ echo -e "\033[0;32m <i> \033[0msudo emerge dev-java/sun-jdk dev-java/sun-jre-bin"
144
+
145
+ elif [ ! -z "$rvm_pacman_binary" ] ; then
146
+ echo -e "\033[0;33m <w> \033[0mFor jRuby (if you wish to use it) you will need:"
147
+ echo -e "\033[0;32m <i> \033[0msudo pacman -Sy jdk jre"
148
+
149
+ elif [ ! -z "$rvm_yum_binary" ] ; then
150
+ echo -e "\033[0;33m <w> \033[0mFor ree (if you wish to use it) you will need:"
151
+ echo -e "\033[0;32m <i> \033[0myum install -y rpm-build gcc gcc-c++ redhat-rpm-config ; then download and rpmbuild and install the sdk, Have fun..."
152
+
153
+ else
154
+ echo -e "\033[0;33m <w> \033[0mFor jRuby (if you wish to use it) you will need:"
155
+ echo -e "\033[0;32m <i> \033[0mThe SUN java runtime environment and development kit."
156
+ fi
157
+ elif [ "$sytem" = "Darwin" ] ; then
158
+ echo -e "\033[0;32m <i> \033[0mBe sure that you have XCode Tools installed in order to use rvm."
159
+ echo -e "\033[0;32m <i> \033[0mIf you intend on installing MacRuby you must install LLVM first."
160
+ fi
161
+
162
+ echo -e "$info There have been a great many updates since previous releases, please:"
163
+ echo -e "$info * remove sourcing of ~/.rvm/current from your shell profiles."
164
+ echo -e "$info * CLOSE THIS SHELL AND OPEN A NEW ONE FOR rvm."
165
+
166
+ echo -e "\n$info Please visit the website for much more information: http://rvm.beginrescueend.com/\n"
167
+ echo ' w⦿‿⦿t! '
168
+ echo -e "\n ~ Wayne"
169
+
170
+ source $rvm_dir/scripts/rvm
171
+
172
+ rvm symlinks
173
+ echo
174
+ rvm -v
175
+ echo
176
+
data/scripts/rvm-utility CHANGED
@@ -4,8 +4,8 @@ function __rvm_meta {
4
4
  rvm_meta_author="Wayne E. Seguin"
5
5
  rvm_meta_author_email="wayneeseguin@gmail.com"
6
6
  rvm_meta_website="http://rvm.beginrescueend.com/"
7
- rvm_meta_version="0.0.37"
8
- rvm_meta_updated="2009.09.09"
7
+ rvm_meta_version="`cat $rvm_path/VERSION.yml | tail -n 3 | sed 's/^.*: //g' | tr "\n" '.' | sed 's/\.$//'`"
8
+ rvm_meta_updated="2009.09.14"
9
9
  }
10
10
 
11
11
  function __rvm_version { __rvm_meta ; echo "rvm $rvm_meta_version ($rvm_meta_updated) [$rvm_meta_website]" ; }
@@ -60,7 +60,7 @@ function __rvm_usage {
60
60
  -p|--prefix - Package and source directory prefix, with trailing slash!
61
61
  Default is a users home directory and /usr/local/ for root
62
62
  -a|--archives - Directory to place downladed files into (~/.rvm/archives/)
63
- -n|--nice - Niceness level (default: 0)
63
+ -n|--nice - Specify a process niceness (for slow computers, default 0)
64
64
  -m|--gem-set - Named gem set for switching between different gem sets
65
65
  --rm-gem-set - Removes a named gemset.
66
66
 
@@ -69,9 +69,9 @@ function __rvm_usage {
69
69
  -r|--rev - Specify the repository revision # to use or 'head' for
70
70
 
71
71
  -P|--prefix - Sets the prefix path for installs to be installed to
72
- -B|--bin - Specify path for binaries to be placed
73
- -S|--source - Specify src directory to use
74
- -A|--archive - Specify archive directory to use (tabralls / zips)
72
+ --bin - Specify path for binaries to be placed
73
+ --source - Specify src directory to use
74
+ --archive - Specify archive directory to use (tabralls / zips)
75
75
  -G|--gems - Specify root gem path to use
76
76
  -C|--configure - Specify custom configure options, comma separated
77
77
  default: --enable-shared=true
@@ -79,11 +79,11 @@ function __rvm_usage {
79
79
  -M|--make - Specify a custom make command
80
80
  -I|--make-install - " a custom make install command
81
81
 
82
- -n|--nice - Specify a process niceness (for slow computers)
83
82
  -f|--file - Specify a ruby file to run with 'rubydo' command
84
83
  -h|--help - Emit this output and exit
85
84
  -d|--default - Set the default Ruby to a specified version
86
85
  -m|--gem-set - Use a named gem set instead of the default set.
86
+ -S|--script - Specify a script file to attempt to load and run (rubydo)
87
87
  --all - Used with 'rvm list' to list "most" installable versions.
88
88
  --rm-gem-set - Remove a named gem set
89
89
  --jit - Enable JIT for the Rubinius build
@@ -155,6 +155,7 @@ function __rvm_log {
155
155
  debug) shift ; echo -e "\n\033[0;35m <d> \033[0m $*" ;;
156
156
  info) shift ; echo -e "\n\033[0;32m <i> \033[0m $*" ;;
157
157
  warn) shift ; echo -e "\n\033[0;33m <w> \033[0m $*" ;;
158
+ error) shift ; echo -e "\n\033[0;31m <e> \033[0m $*" ;;
158
159
  fail) shift ; echo -e "\n\033[0;31m <e> \033[0m $*" ; popd 2> /dev/null ; return 1 ;;
159
160
  *) echo -e "$*"
160
161
  esac
@@ -175,16 +176,22 @@ function __rvm_gi { gem install -q --no-rdoc --no-ri $* ; }
175
176
  function __rvm_run {
176
177
  log_file_name="$1" ; shift
177
178
  command="$*"
179
+ rvm_ruby_log_path=${rvm_ruby_log_path:-$rvm_path/log}
178
180
  mkdir -p $rvm_ruby_log_path
179
181
  if [ $rvm_debug ] ; then __rvm_log "debug" "Executing: $command" ; fi
180
182
  touch $rvm_ruby_log_path/$log_file_name.log $rvm_ruby_log_path/$log_file_name.error.log # for zsh :(
181
- eval "nice -n $rvm_niceness $command" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log
182
- 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
183
+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] $command" | tee $rvm_ruby_log_path/$log_file_name.log > $rvm_ruby_log_path/$log_file_name.error.log
184
+ if [ -z "$rvm_niceness" ] ; then
185
+ eval "$command" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log
186
+ else
187
+ eval "nice -n $rvm_niceness /bin/bash -l -c '$command'" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log
188
+ fi
189
+ if [ $? -gt 0 ] ; then __rvm_log "error" "Error running '$command', please check $rvm_ruby_log_path/$log_file_name.error.log" ; popd 2> /dev/null ; return 1 ; fi
183
190
  unset log_file command
184
191
  }
185
192
 
186
193
  function __rvm_cleanup-variables {
187
- 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
194
+ 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 rvm_summary rvm_ruby_string rvm_make_flags rvm_bin_flag
188
195
  }
189
196
 
190
197
  # TODO: root user loadng of /etc/rvmrc
@@ -193,30 +200,41 @@ function __rvm_load-rvmrc {
193
200
  }
194
201
 
195
202
  function __rvm_bin_scripts {
196
- if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
203
+ # NOTE: This depends on the forthcoming ruby_string select functionality.
204
+ rvm_ruby_binaries=`/bin/ls $rvm_path/*/bin/ruby`
205
+ for rvm_ruby_binary in $rvm_ruby_binaries ; do
206
+ if [ -x $rvm_ruby_binary ] ; then
207
+ rvm_ruby_string=`dirname $rvm_ruby_binary | xargs dirname | xargs basename`
208
+ __rvm_select
209
+ __rvm_bin_script
210
+ fi
211
+ done
212
+ }
197
213
 
198
- ruby_wrapper=$(cat <<-RubyWrapper
214
+ function __rvm_bin_script {
215
+ if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
216
+ ruby_wrapper=$(cat <<RubyWrapper
199
217
  #!/bin/bash
200
- puts "rvm installed ruby binaries should *not* be run as the root user (yet): http://rvm.beginrescueend.com/faq/" if (`whoami`.strip == "root")
218
+ if [ "`whoami`" = "root" ] ; then
219
+ echo "rvm installed ruby binaries should *not* be run as the root user, yet: http://rvm.beginrescueend.com/faq/"
220
+ fi
201
221
  GEM_HOME=$rvm_gem_home ; export GEM_HOME
222
+ GEM_PATH=$rvm_gem_home ; export GEM_PATH
202
223
  MY_RUBY_HOME=$rvm_ruby_home ; export MY_RUBY_HOME
203
224
  PATH=$rvm_ruby_home/bin:$rvm_gem_home/bin:\$PATH ; export PATH
204
-
205
225
  exec "$rvm_ruby_binary" "\$@"
206
226
  RubyWrapper
207
227
  )
208
-
209
228
  echo "$ruby_wrapper" > $rvm_bin_path/$rvm_ruby_package_name
210
229
  unset ruby_wrapper
211
230
  chmod +x $rvm_bin_path/$rvm_ruby_package_name
212
-
213
231
  }
214
232
 
215
233
  function __rvm_fetch {
216
234
 
217
235
  pushd $rvm_archives_path > /dev/null
218
236
  eval $rvm_fetch "$1"
219
- 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
237
+ if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd > /dev/null ; return 1 ; fi
220
238
  popd 2> /dev/null
221
239
 
222
240
  }
@@ -224,7 +242,7 @@ function __rvm_fetch {
224
242
  function __rvm_load-defaults {
225
243
 
226
244
  if [ ! -s $rvm_path/system ] ; then
227
- for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME PATH ; do
245
+ for variable in RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME PATH ; do
228
246
  eval value=\$${variable}
229
247
  if [ -z "$value" ] ; then
230
248
  echo "unset ${variable}" >> $rvm_path/system
@@ -236,38 +254,38 @@ function __rvm_load-defaults {
236
254
  done
237
255
  fi
238
256
 
239
- rvm_default_path=`__rvm_db "rvm_default_path"`
240
- if [ -z "$rvm_default_path" ] ; then
241
- __rvm_clean-path # Clean the path the first time we compute default path.
257
+ rvm_system_path=`__rvm_db "system_path"`
258
+ if [ -z "$rvm_system_path" ] ; then
259
+ __rvm_clean-path # Clean the path the first time we compute system path.
242
260
  __rvm_remove-rvm-from-path
243
- rvm_default_path="$PATH"
244
- __rvm_db "rvm_default_path" "$rvm_default_path"
261
+ rvm_system_path="$PATH"
262
+ __rvm_db "system_path" "$rvm_system_path"
245
263
  fi
246
264
 
247
- rvm_default_ps1=`__rvm_db "rvm_default_ps1"`
248
- if [ -z "$rvm_default_ps1" ] ; then
249
- rvm_default_ps1=$PS1
250
- __rvm_db "rvm_default_ps1" "$rvm_default_ps1"
265
+ rvm_system_ps1=`__rvm_db "system_ps1"`
266
+ if [ -z "$rvm_system_ps1" ] ; then
267
+ rvm_system_ps1=$PS1
268
+ __rvm_db "system_ps1" "$rvm_system_ps1"
251
269
  fi
252
270
 
253
- rvm_default_system_ruby=`__rvm_db "default_system_ruby"`
254
- if [ -z "$rvm_default_system_ruby" ] ; then
255
- rvm_default_system_ruby=`which ruby`
271
+ rvm_system_ruby=`__rvm_db "system_ruby"`
272
+ if [ -z "$rvm_system_ruby" ] ; then
273
+ rvm_system_ruby=`which ruby`
256
274
  if [ $? -ne 0 ] ; then
257
275
  __rvm_log "info" "System ruby not found, no db will be stored."
258
276
  else
259
- __rvm_db "default_system_ruby" "$rvm_default_system_ruby"
277
+ __rvm_db "system_ruby" "$rvm_system_ruby"
260
278
 
261
- # Now store default system & user gem paths
262
- rvm_default_user_gem_path=`__rvm_db "default_user_gem_path"`
263
- if [ -z "$rvm_default_user_gem_path" ] ; then
264
- rvm_default_user_gem_path=`ruby -r rubygems -e "puts Gem::default_path.compact.first"`
265
- __rvm_db "default_user_gem_path" "$rvm_default_user_gem_path"
279
+ # Now store system system & user gem paths
280
+ rvm_system_user_gem_path=`__rvm_db "system_user_gem_path"`
281
+ if [ -z "$rvm_system_user_gem_path" ] ; then
282
+ rvm_system_user_gem_path=`ruby -r rubygems -e "puts Gem::default_path.compact.first"`
283
+ __rvm_db "system_user_gem_path" "$rvm_system_user_gem_path"
266
284
  fi
267
- rvm_default_system_gem_path=`__rvm_db "default_system_gem_path"`
268
- if [ -z "$rvm_default_system_gem_path" ] ; then
269
- rvm_default_system_gem_path=`ruby -r rubygems -e "puts Gem::default_path.compact[1] || Gem::default_path.compact.first"`
270
- __rvm_db "default_system_gem_path" "$rvm_default_system_gem_path"
285
+ rvm_system_gem_path=`__rvm_db "system_gem_path"`
286
+ if [ -z "$rvm_system_gem_path" ] ; then
287
+ rvm_system_gem_path=`ruby -r rubygems -e "puts Gem::default_path.compact[1] || Gem::default_path.compact.first"`
288
+ __rvm_db "system_gem_path" "$rvm_system_gem_path"
271
289
  fi
272
290
  fi
273
291
  fi
@@ -276,18 +294,17 @@ function __rvm_load-defaults {
276
294
 
277
295
  function __rvm_reset {
278
296
 
279
- PATH="$rvm_path/bin:$rvm_default_path" ; export PATH
297
+ PATH="$rvm_path/bin:$rvm_system_path" ; export PATH
280
298
  for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do unset $variable ; done
281
- if [ -f $rvm_path/system ] ; then rm -f $rvm_path/system ; fi
282
- rm -f $rvm_path/default*
283
- # TODO: Remove this after a few releases:
284
- rm -f $rvm_path/current*
285
299
 
300
+ for file in system default ; do
301
+ if [ -f $rvm_path/$file ] ; then rm -f $rvm_path/file ; fi
302
+ done
286
303
  __rvm_select "system"
287
304
 
288
- for default in default_ps1 default_path default_system_ruby default_system_gem_path default_user_gem_path ; do
289
- __rvm_db "$default" "delete"
290
- done ; unset default variable
305
+ for system_config in system_ps1 system_path system_ruby system_gem_path system_user_gem_path ; do
306
+ __rvm_db "$system_config" "delete"
307
+ done ; unset system_config variable
291
308
 
292
309
  }
293
310
 
@@ -296,11 +313,16 @@ function __rvm_implode {
296
313
  __rvm_log "warn" "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')"
297
314
  read response
298
315
  if [ "$response" = "yes" ] ; then
299
- if [ -d $rvm_path ] ; then
300
- __rvm_log "info" "Hai! Removing $rvm_path"
301
- rm -rf $rvm_path/
316
+ if [ "$rvm_path" = "/" ] ; then
317
+ __rvm_log "error" "remove '/' ?!... NO!"
302
318
  else
303
- __rvm_log "info" "It appears that $rvm_path is already non existant."
319
+ if [ -d $rvm_path ] ; then
320
+ __rvm_log "info" "Hai! Removing $rvm_path"
321
+ rm -rf $rvm_path/
322
+ __rvm_log "info" "$rvm_path has been removed."
323
+ else
324
+ __rvm_log "info" "It appears that $rvm_path is already non existant."
325
+ fi
304
326
  fi
305
327
  break
306
328
  elif [ "$response" = "no" ] ; then
@@ -334,11 +356,11 @@ function __rvm_src-dir {
334
356
  function __rvm_gem-dup {
335
357
 
336
358
  if [ "$1" = "default" ] ; then
337
- rvm_source_gem_dir="$rvm_default_user_gem_path"
359
+ rvm_source_gem_dir="$rvm_system_user_gem_path"
338
360
  elif [ "$1" = "system" ] ; then
339
- rvm_source_gem_dir="$rvm_default_system_gem_path"
361
+ rvm_source_gem_dir="$rvm_system_gem_path"
340
362
  else
341
- rvm_source_gem_dir=${1:-$rvm_default_user_gem_path} # TODO: check for and remove trailing /gems
363
+ rvm_source_gem_dir=${1:-$rvm_system_user_gem_path} # TODO: check for and remove trailing /gems
342
364
  fi
343
365
 
344
366
  if [ ! -z "$rvm_source_gem_dir" ] ; then
@@ -366,17 +388,17 @@ function __rvm_db {
366
388
  if [ -z "$key" ] ; then
367
389
  __rvm_log "fail" "__rvm_db must be called with at least one argument: __rvm_db key [value]"
368
390
  else
369
- if [ "$key" = "unset" -o "$key" = "delete" ] ; then
370
- sed -i# "s/^$2=.*$//" $rvm_hash_file
391
+ value="$*"
392
+ if [ "$value" = "unset" -o "$value" = "delete" ] ; then
393
+ sed -i.tmp "s/^$key=.*$//" $rvm_hash_file
371
394
  else
372
- value="$*"
373
395
  if [ -z "$value" ] ; then # get
374
396
  grep "^$key=" $rvm_hash_file | head -n 1 | awk -F'=' '{print $2}'
375
397
  else # set
376
398
  if [ -z "$(grep "^$key=" $rvm_hash_file)" ] ; then # append
377
399
  echo "$key=$value" >> $rvm_hash_file
378
400
  else # overwrite
379
- sed -i# "s/^$key=.*$/$key=$value/" $rvm_hash_file
401
+ sed -i.tmp "s/^$key=.*$/$key=$value/" $rvm_hash_file
380
402
  fi
381
403
  fi
382
404
  fi
@@ -415,41 +437,58 @@ function __rvm_list {
415
437
  current=`which ruby | xargs dirname | xargs dirname | xargs basename`
416
438
  echo -e "\nruby:\n"
417
439
  for version in `/bin/ls -l $rvm_path/ | awk '/ ruby-[1-2].*/ { print $NF }'` ; do
440
+ string=`$rvm_bin_path/$version -v`
418
441
  if [ "$current" = "$version" ] ; then
419
- echo -e "=> $version"
442
+ echo -e "=> $version : $string"
420
443
  selected="1"
421
444
  else
422
- echo -e " $version"
445
+ echo -e " $version : $string"
423
446
  fi
424
447
  done
425
448
  unset version
426
449
 
427
450
  echo -e "\njruby:\n"
428
451
  for version in `/bin/ls -l $rvm_path/ | awk '/jruby-.*/ { print $NF }'` ; do
452
+ string=`$rvm_bin_path/$version -v`
429
453
  if [ "$current" = "$version" ] ; then
430
- echo -e "=> $version"
454
+ echo -e "=> $version : $string"
431
455
  selected="1"
432
456
  else
433
- echo -e " $version"
457
+ echo -e " $version : $string"
434
458
  fi
435
459
  done
436
460
  unset version
437
461
 
438
462
  echo -e "\nree:\n"
439
463
  for version in `/bin/ls $rvm_path/ | awk '/ruby-enterprise-.*/ { print $NF }'` ; do
464
+ string=`$rvm_bin_path/$version -v | tr "\n" ' ' `
440
465
  if [ "$current" = "$version" ] ; then
441
- echo -e "=> $version"
466
+ echo -e "=> $version : $string"
442
467
  selected="1"
443
468
  else
444
- echo -e " $version"
469
+ echo -e " $version : $string"
445
470
  fi
446
471
  done
447
472
 
473
+ if [ -f $rvm_path/default -a -s $rvm_path/default ] ; then
474
+ version=`grep '^MY_RUBY_HOME' ~/.rvm/default | awk -F"'" '{print $2}' | xargs basename`
475
+ if [ ! -z "$version" ] ; then
476
+ echo -e "\ndefault:\n"
477
+ string=`$rvm_bin_path/$version -v`
478
+ if [ "$current" = "$version" ] ; then
479
+ echo -e "=> $version : $string"
480
+ selected="1"
481
+ else
482
+ echo -e " $version : $string"
483
+ fi
484
+ fi
485
+ fi
486
+
448
487
  echo -e "\nsystem:\n"
449
488
  if [ "$selected" = "1" ] ; then
450
- echo -e " $($rvm_default_system_ruby -v)\n"
489
+ echo -e " $($rvm_system_ruby -v)\n"
451
490
  else
452
- echo -e "=> $($rvm_default_system_ruby -v)\n"
491
+ echo -e "=> $($rvm_system_ruby -v)\n"
453
492
  fi
454
493
  unset current version selected
455
494
  fi
@@ -497,6 +536,8 @@ function __rvm_initialize {
497
536
  #rvm_macruby_repo_url="${rvm_macruby_repo_url:-"http://svn.macosforge.org/repository/ruby/MacRuby"}"
498
537
  rvm_macruby_repo_url="${rvm_macruby_repo_url:-"git://github.com/masterkain/macruby.git"}"
499
538
  rvm_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}"
539
+ rvm_ruby_load_path="."
540
+ rvm_ruby_require=""
500
541
 
501
542
  __rvm_clean-path
502
543
  rvm_result=$(echo $PATH | grep 'rvm\/bin:')
@@ -507,3 +548,290 @@ function __rvm_initialize {
507
548
  mkdir -p $rvm_source_path $rvm_bin_path $rvm_archives_path
508
549
  }
509
550
 
551
+ function __rvm_update {
552
+ if [ "$rvm_ruby_rev" = "head" -o "$rvm_update_flag" ] ; then
553
+ __rvm_version
554
+ __rvm_update_rvm
555
+ __rvm_version
556
+ fi
557
+ __rvm_reload
558
+ if [ "$rvm_bin_flag" ] ; then __rvm_bin_scripts ; fi
559
+ if [ "$rvm_rubygems_flag" ] ; then __rvm_rubygems_install ; fi
560
+ }
561
+
562
+ function __rvm_update_rvm {
563
+ mkdir -p $rvm_source_path
564
+ if [ "$rvm_ruby_rev" = "head" ] ; then
565
+ if [ -d $rvm_source_path/rvm/.git ] ; then
566
+ cd $rvm_source_path/rvm/ && git pull origin master && ./scripts/rvm-install
567
+ else
568
+ cd $rvm_source_path && git clone git://github.com/wayneeseguin/rvm.git && cd rvm/ && ./scripts/rvm-install
569
+ fi
570
+ else
571
+ # TODO: rvm_install_path:
572
+ gem install rvm --no-rdoc --no-ri -q && rvm-install && source ~/.rvm/scripts/rvm
573
+ fi
574
+ }
575
+
576
+ function __rvm_reboot {
577
+ __rvm_log "warn" "Do you wish to reset rvm? ('yes', or 'no')"
578
+ read response
579
+ if [ "$response" = "yes" ] ; then
580
+ cd
581
+ __rvm_reset
582
+ mv ~/.rvm/archives ~/.archives
583
+ if [ "$rvm_path" = "/" ] ; then
584
+ __rvm_log "error" "remove '/' ?!... NO!"
585
+ else
586
+ if [ -d $rvm_path ] ; then
587
+ rm -rf $rvm_path/
588
+ fi
589
+ fi
590
+ gem install rvm --no-rdoc --no-ri -q
591
+ which rvm-install > /dev/null
592
+ if [ $? -gt 0 ] ; then
593
+ if [ -e ~/.gem/ruby/1.8/bin/rvm-install ] ; then
594
+ ~/.gem/ruby/1.8/bin/rvm-install
595
+ else
596
+ __rvm_log "error" "Could not find rvm-install in your path :("
597
+ fi
598
+ else
599
+ rvm-install
600
+ fi
601
+ source ~/.rvm/scripts/rvm
602
+ else
603
+ __rvm_log "info" "Carry on then..."
604
+ fi
605
+ unset response
606
+ }
607
+
608
+ function __rvm_reload {
609
+ source $rvm_path/scripts/rvm
610
+ }
611
+
612
+ function __rvm_do {
613
+ all=() ; successes=() ; errors=() ; statuses=()
614
+ # TODO: Extract the common functionality out of the if below
615
+ if [ ! -z "$rvm_ruby_version" ] ; then
616
+ rvm_ruby_selectors=$(echo $rvm_ruby_version | tr ',' ' ')
617
+ for rvm_ruby_selector in $rvm_ruby_selectors ; do
618
+ temp=$(echo $rvm_ruby_selector | awk '{print substr($1, 0, 1)}')
619
+ if [ ! -z "$(echo $temp | grep '[0-9]')" ] ; then
620
+ rvm_ruby_interpreter="ruby"
621
+ rvm_ruby_version="$rvm_ruby_selector"
622
+ else
623
+ rvm_ruby_interpreter="$rvm_ruby_selector"
624
+ unset rvm_ruby_version
625
+ fi
626
+ unset temp
627
+ __rvm_select
628
+ __rvm_use
629
+ binary=`echo $rvm_action | sed 's/do$//'`
630
+ lp="$rvm_ruby_home/bin:$rvm_ruby_load_path"
631
+ if [ "$binary" = "ruby" ] ; then
632
+ rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_require -I$lp -S $rvm_ruby_args"
633
+ else
634
+ rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_args"
635
+ fi
636
+ echo "$rvm_ruby_string: $($rvm_ruby_home/bin/$binary -v)"
637
+ eval $rvm_command
638
+ status=$?
639
+ if [ $status -eq 0 ]; then
640
+ successes[${#successes[*]}]=$rvm_ruby_string
641
+ else
642
+ errors[${#errors[*]}]=$rvm_ruby_string
643
+ fi
644
+ all[${#all[*]}]=$rvm_ruby_string
645
+ statuses[${#statuses[*]}]=$status
646
+ # TODO: keep track of and re-set the previous selected ruby ;)
647
+ unset rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_ruby_package_name rvm_ruby_home rvm_ruby_irbrc rvm_ruby_binary rvm_ruby_string lp
648
+ done
649
+ else # all
650
+ rvm_ruby_binaries=`/bin/ls $rvm_path/*/bin/ruby`
651
+ for rvm_ruby_binary in $rvm_ruby_binaries ; do
652
+ if [ -x $rvm_ruby_binary ] ; then
653
+ rvm_ruby_string=`dirname $rvm_ruby_binary | xargs dirname | xargs basename`
654
+ __rvm_select
655
+ __rvm_use
656
+ rvm_ruby_string="$(dirname $rvm_ruby_home/bin/$binary | xargs dirname | xargs basename)"
657
+ lp="$rvm_ruby_home/bin:$rvm_ruby_load_path"
658
+ if [ "$binary" = "ruby" ] ; then
659
+ rvm_command="$rvm_ruby_binary $rvm_ruby_require -I$lp -S $rvm_ruby_args"
660
+ else
661
+ rvm_command="$rvm_ruby_binary $rvm_ruby_args"
662
+ fi
663
+ echo "$(basename $rvm_ruby_binary):"
664
+ eval $rvm_command
665
+ status=$?
666
+ if [ $status -eq 0 ]; then
667
+ successes[${#successes[*]}]=$rvm_ruby_string
668
+ else
669
+ errors[${#errors[*]}]=$rvm_ruby_string
670
+ fi
671
+ all[${#all[*]}]=$rvm_ruby_string
672
+ statuses[${#statuses[*]}]=$status
673
+ unset rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_ruby_package_name rvm_ruby_home rvm_ruby_irbrc rvm_ruby_binary rvm_ruby_string lp
674
+ fi
675
+ done
676
+ fi
677
+
678
+ export successes errors statuses
679
+
680
+ if [ ! -z "$rvm_summary" ] ; then
681
+ echo -e "\n\033[0;32msuccessful (${#successes[*]}) : [ $(echo "${successes[*]}" | sed 's/ /, /g') ]\033[0m"
682
+ echo -e "\n\033[0;31merrors (${#errors[*]}) : [ $(echo "${errors[*]}" | sed 's/ /, /g') ]\033[0m"
683
+ echo -e "all (${#all[*]}) : [ $(echo "${all[*]}" | sed 's/ /, /g') ]"
684
+ echo -e "exit statuses: [ $(echo "${statuses[*]}" | sed 's/ /, /g') ]\n"
685
+ # unset binary successes errors rvm_summary
686
+ else
687
+ unset binary successes errors rvm_summary
688
+ fi
689
+ return ${#errors[*]}
690
+ }
691
+
692
+ function __rvm_irbrc {
693
+ if [ ! -s "$rvm_ruby_irbrc" ] ; then
694
+ rvm_irbrc_file=`cat <<-Config
695
+ load '$HOME/.irbrc' if File.exists?('$HOME/.irbrc') rescue nil
696
+
697
+ require "irb/completion" rescue nil
698
+
699
+ @prompt = {
700
+ :PROMPT_I => "${rvm_ruby_package_name} > ", # default prompt
701
+ :PROMPT_S => "${rvm_ruby_package_name}%l> ", # known continuation
702
+ :PROMPT_C => "${rvm_ruby_package_name} > ",
703
+ :PROMPT_N => "${rvm_ruby_package_name} ?> ", # unknown continuation
704
+ :RETURN => " => %s \n",
705
+ :AUTO_INDENT => true
706
+ }
707
+ @prompt_mode = :DEFAULT
708
+ IRB.conf[:PROMPT][@prompt_mode] = @prompt
709
+ IRB.conf[:PROMPT_MODE] = @prompt_mode
710
+ Config
711
+ `
712
+ touch $rvm_ruby_home/.irbrc
713
+ echo -e "\n$rvm_irbrc_file" > $rvm_ruby_home/.irbrc
714
+ fi
715
+
716
+ }
717
+
718
+ function __rvm_ruby_string {
719
+ if [ "$rvm_ruby_interpreter" = "system" ] ; then
720
+ rvm_ruby_string=""
721
+ elif [ ! -z "$rvm_ruby_string" ] ; then
722
+ echo $rvm_ruby_string | grep "enterprise" > /dev/null
723
+ if [ $? -eq 0 ] ; then
724
+ rvm_ruby_interpreter="ruby-enterprise"
725
+ else
726
+ rvm_ruby_interpreter=`echo $rvm_ruby_string | tr '-' ' ' | awk '{print $1}'`
727
+ fi
728
+ rvm_ruby_vesion=`echo $rvm_ruby_string | awk -F'-' '{print $(NF-1)}'`
729
+ revision=`echo $rvm_ruby_string | awk '{print $NF}'`
730
+ if [ "$revision" = "head" -o "$revision" = "preview" ] ; then
731
+ rvm_ruby_revision="$revision"
732
+ else
733
+ echo $revision | grep 'p[0-9]\+' > /dev/null
734
+ if [ $? -eq 0 ] ; then
735
+ rvm_ruby_patch_level=`echo $revision | awk -F'p' '{print $2}'`
736
+ else
737
+ echo $revision | grep '[0-9]\+' > /dev/null
738
+ if [ $? -eq 0 ] ; then
739
+ rvm_ruby_rev="$revision"
740
+ else
741
+ unset rvm_ruby_patch_level rvm_ruby_rev
742
+ fi
743
+ fi
744
+ fi
745
+ fi
746
+ return 0
747
+ }
748
+
749
+ function __rvm_gemset_dump {
750
+ if [ -z "$rvm_gem_set_name" ] ; then
751
+ file_name="default"
752
+ else
753
+ file_name="$rvm_gem_set_name"
754
+ fi
755
+
756
+ 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
757
+
758
+ gems="`gem list | sed 's/[\(|\)]//g' | sed 's/, /,/g' | tr ' ' ';'`"
759
+ for gem in $gems ; do
760
+ name=`echo $gem | awk -F';' '{print $1}'`
761
+ if [ -z "$rvm_gem_latest" ] ; then
762
+ versions=`echo $gem | awk -F';' '{print $2}' | sed 's/,/ /g'`
763
+ for version in $versions ; do
764
+ echo "$name -v$version" >> $file_name.gemset
765
+ done
766
+ unset version
767
+ else
768
+ echo "$name" >> $file_name.gemset
769
+ fi
770
+ unset name
771
+ done
772
+ unset file_name gems versions
773
+ }
774
+
775
+ function __rvm_gemset_load {
776
+ echo "Loading $rvm_load_file file..."
777
+ while read line < `cat "$rvm_load_file" | awk '/^[a-zA-Z]/{print}'` ; do
778
+ # TODO: Switch to a different field separator than ; to allow for evals
779
+ gem=`echo $line | awk -F';' '{print $1}'`
780
+ gem_prefix=`echo $line | awk -F';' '{print $2}'`
781
+ gem_name=`echo $gem | awk '{print $1}'`
782
+ gem_version=`echo $gem | sed 's/^.*-v[=]*[ ]*//' | awk '{print $1}'`
783
+ gem_postfix=`echo $gem | sed "s/$gem_name//" | sed "s/-v[=]*[ ]*$gem_version//"`
784
+ gem_file="$gem_name-$gem_version.gem"
785
+
786
+ if [ -z "$gem_version" ] ; then # no version
787
+ file=`/bin/ls -t $rvm_gem_home/cache/${gem_name}* | head -n 1`
788
+ else # version
789
+ file=`/bin/ls $rvm_gem_home/cache/$gem_file`
790
+ fi
791
+
792
+ if [ -z "$file" ] ; then # not cached
793
+ gem="$gem_name-$gem_version"
794
+ else # cached
795
+ gem="$file -l" # install as a named local gem
796
+ fi
797
+
798
+ # TODO: Set vars if fourth field is non-empty (means that there are conditional statements to execute in the gem install line.
799
+ if [ -z "$vars" ] ; then
800
+ GEM_HOME="$rvm_gem_home" GEM_PATH="$rvm_gem_home" $gem_prefix $rvm_ruby_home/bin/gem install --no-rdoc --no-ri -q $gem $gem_postfix
801
+ else
802
+ eval "GEM_HOME='$rvm_gem_home' GEM_PATH='$rvm_gem_home' $gem_prefix $rvm_ruby_home/bin/gem install --no-rdoc --no-ri -q $gem $gem_postfix"
803
+ fi
804
+ unset gem gem_prefix gem_name gem_version gem_file gem_postfix file
805
+ done
806
+ }
807
+
808
+ # -C --with-readline-dir=$rvm_path/usr
809
+ function __rvm_readline_install {
810
+ pushd $rvm_path/src > /dev/null
811
+ package=readline
812
+ version=5.2
813
+ # TODO: Figure out how to list, grab and apply the patches
814
+ __rvm_fetch "ftp://ftp.gnu.org/gnu/readline/$package-$version.tar.gz"
815
+ __rvm_run "extract" tar zxf $rvm_archives_path/$package-$version.tar.gz -C $rvm_path/src/
816
+ cd $rvm_path/src/$package-$version
817
+ __rvm_run "configure" ./configure --prefix=$rvm_path/usr --disable-dependency-tracking --disable-static --enable-shared
818
+ __rvm_run "$package.make" make
819
+ __rvm_run "$package.make.install" make install
820
+ popd > /dev/null
821
+ }
822
+
823
+ # -C --with-iconv-dir=$rvm_path/usr
824
+ function __rvm_iconv_install {
825
+ pushd $rvm_path/src > /dev/null
826
+ package=libiconv
827
+ version=1.13.1
828
+ __rvm_fetch "http://ftp.gnu.org/pub/gnu/libiconv/$package-$version.tar.gz"
829
+ __rvm_run "$package.extract" tar zxf $rvm_archives_path/$package-$version.tar.gz -C $rvm_dir/src/
830
+ cd $rvm_path/src/$package-$version
831
+ __rvm_run "$package.configure" ./configure --prefix=$rvm_path/usr --disable-shared
832
+ __rvm_run "$package.make" make
833
+ __rvm_run "$package.make.install" make install
834
+
835
+ popd > /dev/null
836
+ }
837
+