rvm 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bash/rvm CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/bin/bash
2
2
 
3
- rvm_author="Wayne E. Seguin"
4
- rvm_author_email="wayneeseguin@gmail.com"
5
- rvm_website="http://rvm.beginrescueend.com/"
6
- rvm_version="0.0.22"
7
- rvm_updated="2009.08.25"
3
+ rvm_meta_author="Wayne E. Seguin"
4
+ rvm_meta_author_email="wayneeseguin@gmail.com"
5
+ rvm_meta_website="http://rvm.beginrescueend.com/"
6
+ rvm_meta_version="0.0.23"
7
+ rvm_meta_updated="2009.08.25"
8
8
 
9
9
  #
10
10
  # License: See LICENSE
@@ -40,12 +40,13 @@ function rvm-usage {
40
40
  list - Show currently installed versions
41
41
  gemdir - Switch to gem directory for installation (new login shell)
42
42
  srcdir - Switch to src directory for the current ruby installation
43
- gemdup - Clone source version gems to current version
43
+ gemdup - Clone source version gems to current version
44
44
  (highly expiramental) Example: rvm gemdup ~/.gem/ruby/1.8/
45
45
  install - Install a ruby version, default is from source
46
46
  uninstall - Uninstall a ruby version
47
47
  reset - Remove default and current settings, exit the shell.
48
48
  (If you experience odd behavior try this first)
49
+ reload - Reload rvm source itself (useful after changing rvm source)
49
50
  debug - Emit environment & configuration information for *current* ruby
50
51
 
51
52
  Implementation:
@@ -55,14 +56,16 @@ function rvm-usage {
55
56
  ree - Ruby Enterprise Edition
56
57
  default - Resets to the default system ruby
57
58
  all - Used with install, installs all latest known versions
58
-
59
- Options:
59
+
60
+ Options:
60
61
 
61
62
  -v|--version - Ruby Package Version, defaults to 'latest'
62
63
  -l|--level - Patch level for the specified Ruby version
63
64
  -p|--prefix - Package and source directory prefix, with trailing slash!
64
65
  Default is a users home directory and /usr/local/ for root
65
66
  -c|--configure - Options for source compile (default: --enable-shared)
67
+ -a|--archives - Directory to place downladed files into (~/.rvm/archives/)
68
+ -n|--nice - Niceness level (default: 0)
66
69
  -d|--debug - Toggle debug mode on for extra messages (NYI)
67
70
 
68
71
  Notes:
@@ -91,36 +94,11 @@ function rvm-usage {
91
94
 
92
95
  TODO: (in order)
93
96
 
94
- * rvm gemdup
97
+ * rvm gemdup
95
98
  * root support
96
99
  * Settings file, user overridable
97
100
  * Show current in rvm list, if applicable
98
101
 
99
- Many Thanks:
100
-
101
- Bash Support Testing
102
-
103
- - Daniel Neighman (dneighman@gmail.com)
104
- irc: hassox ; github: http://github.com/hassox
105
-
106
- - John Mettraux (jmettraux@openwfe.org)
107
- irc: jmettraux ; github: http://github.com/jmettraux
108
-
109
- ZSH Support Testing
110
-
111
- - Franco Lazzarino (flazzarino@gmail.com)
112
- irc: flazz ; github: http://github.com/flazz
113
-
114
- Ubuntu Linux Support Testing
115
-
116
- - Anita Kuno (anteaya@anteaya.info)
117
- irc: anteaya ; github: http://github.com/anteaya
118
-
119
- Website Design
120
-
121
- - Jim Lindley (jlindley@gmail.com)
122
- irc: jlindley ; github: http://github.com/jlindley
123
-
124
102
  Usage
125
103
 
126
104
  }
@@ -148,8 +126,8 @@ ruby:
148
126
  full_version: "$(ruby -v)"
149
127
 
150
128
  homes:
151
- gem: "${GEM_HOME-not set}"
152
- ruby: "${MY_RUBY_HOME-not set}"
129
+ gem: "${GEM_HOME:-not set}"
130
+ ruby: "${MY_RUBY_HOME:-not set}"
153
131
 
154
132
  binaries:
155
133
  ruby: "$(which ruby)"
@@ -160,169 +138,184 @@ Info
160
138
 
161
139
  }
162
140
 
141
+ function rvm-curl {
142
+ pushd $rvm_archives_path > /dev/null
143
+ eval $rvm_curl "$1"
144
+ popd > /dev/null
145
+ }
146
+
163
147
  function rvm-install-source {
164
148
 
165
- version="${1:-1.8.6}"
166
- case "$version" in
167
- 1.9|1.9.1) major="1.9" ; minor="1" ; level="${2-243}" ;;
168
- 1.9.2) major="1.9" ; minor="2" ; level="${2-review1}" ;;
169
- 1.8|1.8.6) major="1.8" ; minor="6" ; level="${2-369}" ;;
170
- 1.8.7) major="1.8" ; minor="7" ; level="${2-174}" ;;
171
- *) rvm-log-fail "Ruby version '$version' is unknown."
149
+ rvm_version="${1:-1.8.6}"
150
+ case "$rvm_version" in
151
+ 1.9|1.9.1) rvm_major="1.9" ; rvm_minor="1" ; rvm_patch_level="${2:-243}" ;;
152
+ 1.9.2) rvm_major="1.9" ; rvm_minor="2" ; rvm_patch_level="${2:-review1}" ;;
153
+ 1.8|1.8.6) rvm_major="1.8" ; rvm_minor="6" ; rvm_patch_level="${2:-369}" ;;
154
+ 1.8.7) rvm_major="1.8" ; rvm_minor="7" ; rvm_patch_level="${2:-174}" ;;
155
+ *) rvm-log-fail "Ruby version '$rvm_version' is unknown."
172
156
  esac
173
157
 
174
- package_name="ruby-$major.$minor-p$level"
175
- url="ftp://ftp.ruby-lang.org/pub/ruby/$major/$package_name.tar.gz"
176
-
177
- rvm-log-info "Installing Ruby from source to: $install_path/$package_name"
178
- mkdir -p $install_path/$package_name
179
-
180
- pushd $source_path > /dev/null
181
- if [ -d $package_name ] ; then
182
- cd $package_name
158
+ rvm_package_name="ruby-$rvm_major.$rvm_minor-p$rvm_patch_level"
159
+ rvm_url="ftp://ftp.ruby-lang.org/pub/ruby/$major/$rvm_package_name.tar.gz"
160
+
161
+ rvm-log-info "Installing Ruby from source to: $rvm_install_path/$rvm_package_name"
162
+ mkdir -p $rvm_log_path/$rvm_package_name
163
+
164
+ pushd $rvm_source_path > /dev/null
165
+ if [ -d $rvm_package_name ] ; then
166
+ cd $rvm_package_name
183
167
  else
184
- if [ ! -f "$package_name.tar.gz" ] ; then
185
- rvm-log-info "\tDownloading $package_name, this may take a while depending on your connection..."
186
- eval $curl $url
168
+ if [ ! -f "$rvm_archives_path/$rvm_package_name.tar.gz" ] ; then
169
+ rvm-log-info "\tDownloading $rvm_package_name, this may take a while depending on your connection..."
170
+ rvm-curl $rvm_url
187
171
  fi
188
- rvm-log-info "\tExtracting $package_name..."
189
- tar xzf $package_name.tar.gz && cd $package_name
172
+ rvm-log-info "\tExtracting $rvm_package_name..."
173
+ mkdir -p $rvm_source_path/$rvm_package_name
174
+ nice -n $niceness tar xzf $rvm_archives_path/$rvm_package_name.tar.gz -C $rvm_source_path
190
175
  fi
191
176
 
192
- rvm-log-info "\tConfiguring $package_name using ${configure-'--enable-shared'}, this may take a while depending on your cpu(s)..."
193
- ./configure --prefix=$install_path/$package_name ${configure-'--enable-shared'} > $install_path/$package_name/configure.log 2> $install_path/$package_name/configure.error.log
177
+ cd $rvm_source_path/$rvm_package_name
178
+ rvm-log-info "\tConfiguring $rvm_package_name using ${configure:-"--enable-shared"}, this may take a while depending on your cpu(s)..."
179
+ nice -n $niceness ./configure --prefix=$rvm_install_path/$rvm_package_name ${configure:-"--enable-shared"} > $rvm_log_path/$rvm_package_name/configure.log 2> $rvm_log_path/$rvm_package_name/configure.error.log
194
180
 
195
- rvm-log-info "\tCompiling $package_name, this may take a while, depending on your cpu(s)..."
196
- make > $install_path/$package_name/make.log 2> $install_path/$package_name/make.error.log
181
+ rvm-log-info "\tCompiling $rvm_package_name, this may take a while, depending on your cpu(s)..."
182
+ nice -n $niceness make > $rvm_log_path/$rvm_package_name/make.log 2> $rvm_log_path/$rvm_package_name/make.error.log
197
183
 
198
- rvm-log-info "\tInstalling $package_name"
199
- make install > $install_path/$package_name/install.log 2> $install_path/$package_name/install.error.log
200
- chmod +x $install_path/$package_name/bin/*
184
+ rvm-log-info "\tInstalling $rvm_package_name"
185
+ nice -n $niceness make install > $rvm_log_path/$rvm_package_name/install.log 2> $rvm_log_path/$rvm_package_name/install.error.log
186
+ chmod +x $rvm_install_path/$rvm_package_name/bin/*
201
187
 
202
- # Create the ~/.rvm/bin/$package_name
203
- ln -fs $install_path/$package_name/bin/ruby $install_path/bin/$package_name
188
+ ln -fs $rvm_install_path/$rvm_package_name/bin/ruby $rvm_install_path/bin/$rvm_package_name
204
189
 
205
- # Now install rubygems for this ruby version.
206
- rvm-log-info "\tInstalling rubygems dedicated to $package_name..."
207
- gem_package_name="rubygems-1.3.5"
208
- gem_url="http://rubyforge.org/frs/download.php/60718/$gem_package_name.tgz"
209
- if [ -d $gem_package_name ] ; then
210
- cd $gem_package_name
190
+ rvm-log-info "\tInstalling rubygems dedicated to $rvm_package_name..."
191
+ rvm_gem_package_name="rubygems-1.3.5"
192
+ rvm_gem_url="http://rubyforge.org/frs/download.php/60718/$rvm_gem_package_name.tgz"
193
+ if [ -d $rvm_source_path/$rvm_gem_package_name ] ; then
194
+ cd $rvm_source_path/$rvm_gem_package_name
211
195
  else
212
- if [ ! -f $gem_package_name.tgz ] ; then eval $curl $gem_url ; fi
213
- tar zxf $gem_package_name.tgz && cd $gem_package_name
196
+ if [ ! -f "$rvm_archives_path/$rvm_gem_package_name.tgz" ] ; then rvm-curl $rvm_gem_url ; fi
197
+ mkdir -p $rvm_source_path/$rvm_gem_package_name
198
+ nice -n $niceness tar zxf $rvm_archives_path/$rvm_gem_package_name.tgz -C $rvm_source_path
214
199
  fi
215
200
  # Well this is fun... fix nil error on require_paths:
216
- sed -i '' "s/require_paths\.join/require_paths.to_a.join/" $source_path/$package_name/$gem_package_name/lib/rubygems/gem_path_searcher.rb
217
- $install_path/$package_name/bin/ruby ./setup.rb > $install_path/$package_name/rubygems.install.log 2> $install_path/$package_name/rubygems.install.error.log
201
+ sed -i.orig "s/require_paths\.join/require_paths.to_a.join/" $rvm_source_path/$rvm_gem_package_name/lib/rubygems/gem_path_searcher.rb
202
+
203
+ nice -n $niceness $rvm_install_path/$rvm_package_name/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb > $rvm_log_path/$rvm_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_package_name/rubygems.install.error.log
218
204
  popd > /dev/null
219
- rvm-log-info "Installation of $package_name complete."
205
+ rvm-log-info "Installation of $rvm_package_name complete."
220
206
 
221
207
  for gem_name in rake ; do
222
208
  rvm-log-info "Installing $gem_name"
223
- $install_path/$package_name/bin/gem install $gem_name --no-rdoc --no-ri -q >> $install_path/$package_name/gems.install.log
209
+ nice -n $niceness $rvm_install_path/$rvm_package_name/bin/gem install $gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_package_name/gems.install.log 2> $rvm_log_path/$rvm_package_name/gems.error.log
224
210
  done
225
211
  }
226
212
 
227
213
  function rvm-install-ruby {
228
214
 
229
- ruby_options=$RUBYOPT ; unset RUBYOPT
215
+ if [ -z "$RUBYOPT" ] ; then
216
+ ruby_options=$RUBYOPT ; unset RUBYOPT
217
+ fi
230
218
 
231
- case "$implementation" in
219
+ case "$rvm_implementation" in
232
220
 
233
221
  ree)
234
- version=${version-1.8.6}
235
- patchlevel=${patchlevel-20090610}
236
- package_name="ruby-enterprise-$version-$patchlevel"
237
- url="http://rubyforge.org/frs/download.php/58677/$package_name.tar.gz"
238
- rvm-log-info "Installing Ruby Enterprise Edition from source to: $install_path/$package_name"
239
- pushd $source_path > /dev/null
240
- if [ -d $package_name ] ; then
241
- cd $package_name
222
+ rvm_version=${rvm_version:-1.8.6}
223
+ rvm_patchlevel=${rvm_patchlevel:-20090610}
224
+ rvm_package_name="ruby-enterprise-$rvm_version-$rvm_patchlevel"
225
+ rvm_url="http://rubyforge.org/frs/download.php/58677/$rvm_package_name.tar.gz"
226
+ rvm-log-info "Installing Ruby Enterprise Edition from source to: $rvm_install_path/$rvm_package_name"
227
+ pushd $rvm_source_path > /dev/null
228
+ if [ -d $rvm_source_path/$rvm_package_name ] ; then
229
+ cd $rvm_source_path/$rvm_package_name
242
230
  else
243
- if [ ! -f "$package_name.tar.gz" ] ; then
244
- rvm-log-info "\tDownloading $package_name, this may take a while depending on your connection..."
245
- eval $curl $url
231
+ if [ ! -f "$rvm_archives_path/$rvm_package_name.tar.gz" ] ; then
232
+ rvm-log-info "\tDownloading $rvm_package_name, this may take a while depending on your connection..."
233
+ rvm-curl $rvm_url
246
234
  fi
247
- rvm-log-info "\tExtracting $package_name..."
248
- tar xzf $package_name.tar.gz && cd $package_name
235
+ rvm-log-info "\tExtracting $rvm_package_name..."
236
+ mkdir -p $rvm_source_path/$rvm_package_name
237
+ nice -n $niceness tar xzf $rvm_archives_path/$rvm_package_name.tar.gz -C $rvm_source_path
249
238
  fi
250
239
 
251
- rvm-log-info "\tInstalling $package_name, this may take a while, depending on your cpu(s)..."
252
- mkdir -p $install_path/$package_name
253
- ./installer -a $install_path/ruby-enterprise-$version-$patchlevel --dont-install-useful-gems > $install_path/$package_name/install.log 2> $install_path/$package_name/install.error.log
254
- chmod +x $install_path/$package_name/bin/*
240
+ rvm-log-info "\tInstalling $rvm_package_name, this may take a while, depending on your cpu(s)..."
241
+ mkdir -p $rvm_log_path/$rvm_package_name
242
+
243
+ cd $rvm_source_path/$rvm_package_name
244
+ nice -n $niceness ./installer -a $rvm_install_path/ruby-enterprise-$rvm_version-$rvm_patchlevel --dont-install-useful-gems > $rvm_log_path/$rvm_package_name/install.log 2> $rvm_log_path/$rvm_package_name/install.error.log
245
+ chmod +x $rvm_install_path/$rvm_package_name/bin/*
255
246
 
256
- ln -fs $install_path/$package_name/bin/ruby $install_path/bin/$package_name
247
+ ln -fs $rvm_install_path/$rvm_package_name/bin/ruby $rvm_install_path/bin/$rvm_package_name
257
248
 
258
- rvm-log-info "\tInstalling rubygems dedicated to $package_name..."
259
- gem_package_name="rubygems-1.3.5"
260
- gem_url="http://rubyforge.org/frs/download.php/60718/$gem_package_name.tgz"
261
- if [ -d $gem_package_name ] ; then
262
- cd $gem_package_name
249
+ rvm-log-info "\tInstalling rubygems dedicated to $rvm_package_name..."
250
+ rvm_gem_package_name="rubygems-1.3.5"
251
+ rvm_gem_url="http://rubyforge.org/frs/download.php/60718/$rvm_gem_package_name.tgz"
252
+ if [ -d $rvm_source_path/$rvm_gem_package_name ] ; then
253
+ cd $rvm_source_path/$rvm_gem_package_name
263
254
  else
264
- if [ ! -f $gem_package_name.tgz ] ; then eval $curl $gem_url ; fi
265
- tar zxf $gem_package_name.tgz && cd $gem_package_name
255
+ if [ ! -f "$rvm_archives_path/$rvm_gem_package_name.tgz" ] ; then rvm-curl $rvm_gem_url ; fi
256
+ mkdir -p $rvm_source_path/$rvm_gem_package_name
257
+ nice -n $niceness tar zxf $rvm_archives_path/$rvm_gem_package_name.tgz -C $rvm_source_path
266
258
  fi
267
259
  # Well this is fun... fix nil error on require_paths:
268
- sed -i '' "s/require_paths\.join/require_paths.to_a.join/" $source_path/$package_name/$gem_package_name/lib/rubygems/gem_path_searcher.rb
269
- $install_path/$package_name/bin/ruby ./setup.rb > $install_path/$package_name/rubygems.install.log 2> $install_path/$package_name/rubygems.install.error.log
270
- rvm-log-info "Installation of $package_name complete."
260
+ sed -i.orig "s/require_paths\.join/require_paths.to_a.join/" $rvm_source_path/$rvm_gem_package_name/lib/rubygems/gem_path_searcher.rb > $rvm_log_path/$rvm_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_package_name/rubygems.install.error.log
261
+
262
+ nice -n $niceness $rvm_install_path/$rvm_package_name/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb > $rvm_log_path/$rvm_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_package_name/rubygems.install.error.log
263
+ rvm-log-info "Installation of $rvm_package_name complete."
271
264
  popd > /dev/null
272
-
265
+
273
266
  for gem_name in rake ; do
274
267
  rvm-log-info "Installing $gem_name"
275
- $install_path/$package_name/bin/gem install $gem_name --no-rdoc --no-ri -q >> $install_path/$package_name/gems.install.log
268
+ nice -n $niceness $rvm_install_path/$rvm_package_name/bin/gem install $gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_package_name/gems.install.log 2> $rvm_log_path/$rvm_package_name/gems.error.log
276
269
  done
277
270
  ;;
278
271
 
279
272
  jruby)
280
- version=${version-1.3.1} # 1.2.0, 1.3.1
281
- unset patchlevel # No patchlevel for jRuby
282
- zipfile="$implementation-bin-$version"
283
- package_name="$implementation-$version"
284
- url="http://dist.codehaus.org/$implementation/$version/$zipfile.zip"
285
-
286
- rvm-log-info "Installing jRuby to: $install_path/$package_name"
287
- mkdir -p $install_path/$package_name
288
- pushd $source_path > /dev/null
289
- if [ -d $zipfile ] ; then
290
- cd $zipfile
273
+ rvm_version=${rvm_version:-1.3.1} # 1.2.0, 1.3.1
274
+ unset rvm_patchlevel # No patchlevel for jRuby
275
+ rvm_package_file="$rvm_implementation-bin-$rvm_version"
276
+ rvm_package_name="$rvm_implementation-$rvm_version"
277
+ rvm_url="http://dist.codehaus.org/$rvm_implementation/$rvm_version/$rvm_package_file.zip"
278
+
279
+ rvm-log-info "Installing jRuby to: $rvm_install_path/$rvm_package_name"
280
+ mkdir -p $rvm_log_path/$rvm_package_name
281
+ pushd $rvm_source_path > /dev/null
282
+ if [ -d $rvm_package_name ] ; then
283
+ cd $rvm_source_path/$rvm_package_name
291
284
  else
292
- if [ ! -f "$zipfile.zip" ] ; then
293
- rvm-log-info "\tDownloading $zipfile, this may take a while depending on your connection..."
294
- eval $curl $url
285
+ if [ ! -f "$rvm_archives_path/$rvm_package_file.zip" ] ; then
286
+ rvm-log-info "\tDownloading $rvm_package_file, this may take a while depending on your connection..."
287
+ rvm-curl $rvm_url
295
288
  fi
296
- rvm-log-info "\tExtracting $zipfile..."
297
- jar xf $zipfile.zip
289
+ rvm-log-info "\tExtracting $rvm_package_file..."
290
+ nice -n $niceness unzip -q $rvm_archives_path/$rvm_package_file.zip -d $rvm_source_path
298
291
  fi
299
292
 
300
- rvm-log-info "\tInstalling $package_name..."
301
- mkdir -p $install_path/$package_name/bin/
302
- rsync -ag $source_path/$package_name/ $install_path/$package_name/
303
- cd $source_path/$package_name/tool/nailgun && make > $install_path/$package_name/install.nailgun.log 2> $install_path/$package_name/install.error.nailgun.log
293
+ rvm-log-info "\tInstalling $rvm_package_name..."
294
+ mkdir -p $rvm_install_path/$rvm_package_name/bin/
295
+ rsync -ag $rvm_source_path/$rvm_package_name/ $rvm_install_path/$rvm_package_name/
296
+ cd $rvm_source_path/$rvm_package_name/tool/nailgun && make > $rvm_log_path/$rvm_package_name/install.nailgun.log 2> $rvm_log_path/$rvm_package_name/install.error.nailgun.log
304
297
  popd > /dev/null
305
- chmod +x $install_path/$package_name/bin/*
298
+ chmod +x $rvm_install_path/$rvm_package_name/bin/*
306
299
  for binary in jruby jgem jirb ; do
307
- ln -fs $install_path/$package_name/bin/$binary $install_path/$package_name/bin/${binary#j}
300
+ ln -fs $rvm_install_path/$rvm_package_name/bin/$binary $rvm_install_path/$rvm_package_name/bin/${binary#j}
308
301
  done
309
302
 
310
- ln -fs $install_path/$package_name/bin/ruby $install_path/bin/$package_name
303
+ ln -fs $rvm_install_path/$rvm_package_name/bin/ruby $rvm_install_path/bin/$rvm_package_name
311
304
 
312
305
  for gem_name in rake jruby-openssl ; do
313
306
  rvm-log-info "Installing $gem_name"
314
- $install_path/$package_name/bin/jgem install $gem_name --no-rdoc --no-ri -q >> $install_path/$package_name/gems.install.log
307
+ nice -n $niceness $rvm_install_path/$rvm_package_name/bin/jgem install $gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_package_name/gems.install.log 2> $rvm_log_path/$rvm_package_name/gems.error.log
315
308
  done
316
309
  ;;
317
310
 
318
311
  ruby)
319
- rvm-install-source ${version-1.8.6} ${patchlevel-$3}
312
+ rvm-install-source ${rvm_version:-1.8.6} ${rvm_patchlevel:-$3}
320
313
  ;;
321
314
 
322
315
  default)
323
316
  rvm-log-fail "please specify a ruby implementation to install."
324
317
  ;;
325
- *) rvm-log-fail "Ruby implementation '$implementation' is not known."
318
+ *) rvm-log-fail "Ruby implementation '$rvm_implementation' is not known."
326
319
 
327
320
  esac
328
321
 
@@ -334,150 +327,150 @@ function rvm-install-ruby {
334
327
 
335
328
  function rvm-uninstall {
336
329
 
337
- implementation="${1-$implementation}"
338
- case "$implementation" in
330
+ rvm_implementation="${1:-$rvm_implementation}"
331
+ case "$rvm_implementation" in
339
332
 
340
333
  jruby)
341
- version="${version-1.3.1}"
342
- if [ "$version" = "1.2.0" -o "$version" = "1.3.1" ] ; then
343
- package_name="jruby*-$version"
334
+ rvm_version="${rvm_version:-1.3.1}"
335
+ if [ "$rvm_version" = "1.2.0" -o "$rvm_version" = "1.3.1" ] ; then
336
+ rvm_package_name="jruby*-$rvm_version"
344
337
  else
345
- rvm-log-fail "Unknown jRuby version: $version"
338
+ rvm-log-fail "Unknown jRuby version: $rvm_version"
346
339
  fi
347
340
  ;;
348
341
 
349
342
  ree)
350
- version=${version-1.8.6}
351
- if [ "$version" = "1.8.6" ] ; then
352
- package_name="ruby-enterprise-$version-${3-20090610}"
343
+ rvm_version=${rvm_version:-1.8.6}
344
+ if [ "$rvm_version" = "1.8.6" ] ; then
345
+ rvm_package_name="ruby-enterprise-$rvm_version-${3:-20090610}"
353
346
  else
354
- rvm-log-fail "Unknown Ruby Enterprise Edition version: $version"
347
+ rvm-log-fail "Unknown Ruby Enterprise Edition version: $rvm_version"
355
348
  fi
356
349
  ;;
357
350
 
358
351
  ruby)
359
- if [ "$version" = "1.8.7" ] ; then
360
- package_name="ruby-1.8.7-p${patchlevel-174}"
352
+ if [ "$rvm_version" = "1.8.7" ] ; then
353
+ rvm_package_name="ruby-1.8.7-p${rvm_patchlevel:-174}"
361
354
 
362
- elif [ "$version" = "1.8.6" -o "$version" = "1.8" ] ; then
363
- package_name="ruby-1.8.6-p${patchlevel-369}"
355
+ elif [ "$rvm_version" = "1.8.6" -o "$rvm_version" = "1.8" ] ; then
356
+ rvm_package_name="ruby-1.8.6-p${rvm_patchlevel:-369}"
364
357
 
365
- elif [ "$version" = "1.9.2" ] ; then
366
- package_name="ruby-1.9.2-p${patchlevel-review1}"
358
+ elif [ "$rvm_version" = "1.9.2" ] ; then
359
+ rvm_package_name="ruby-1.9.2-p${rvm_patchlevel:-review1}"
367
360
 
368
- elif [ "$version" = "1.9.1" -o "$version" = "1.9" ] ; then
369
- package_name="ruby-1.9.1-p${patchlevel-243}"
361
+ elif [ "$rvm_version" = "1.9.1" -o "$rvm_version" = "1.9" ] ; then
362
+ rvm_package_name="ruby-1.9.1-p${rvm_patchlevel:-243}"
370
363
 
371
364
  else
372
- rvm-log-fail "Unknown ruby version: $version"
365
+ rvm-log-fail "Unknown ruby version: $rvm_version"
373
366
  fi
374
367
  ;;
375
368
 
376
369
  *)
377
- rvm-log-fail "Ruby implementation '$implementation' is not known."
370
+ rvm-log-fail "Ruby implementation '$rvm_implementation' is not known."
378
371
 
379
372
  esac
380
373
 
381
- if [ ! -z "$package_name" ] ; then
382
- for path in $source_path $install_path ; do
383
- if [ -d $path/$package_name ] ; then
384
- rvm-log-info "Removing $path/$package_name..."
385
- rm -rf $path/$package_name
374
+ if [ ! -z "$rvm_package_name" ] ; then
375
+ for path in $rvm_source_path $rvm_install_path ; do
376
+ if [ -d $path/$rvm_package_name ] ; then
377
+ rvm-log-info "Removing $path/$rvm_package_name..."
378
+ rm -rf $path/$rvm_package_name
386
379
  fi
387
380
  done
388
381
  else
389
- rvm-log-fail "Cannot uninstall unknown package '$package_name'"
382
+ rvm-log-fail "Cannot uninstall unknown package '$rvm_package_name'"
390
383
  fi
391
384
 
392
385
  }
393
386
 
394
387
  function rvm-use {
395
388
 
396
- implementation="${1-$implementation}"
397
- case "$implementation" in
389
+ rvm_implementation="${1:-$rvm_implementation}"
390
+ case "$rvm_implementation" in
398
391
 
399
392
  default)
400
- rm -f $install_path/current
401
- source $install_path/default
393
+ rm -f $rvm_install_path/current
402
394
  unset GEM_HOME MY_RUBY_HOME
395
+ source $rvm_install_path/default
403
396
  PATH="$default_path" ; export PATH
404
397
  ;;
405
398
 
406
399
  jruby)
407
- version="${version-1.3.1}"
408
- if [ "$version" = "1.2.0" -o "$version" = "1.3.1" ] ; then
409
- MY_RUBY_HOME="$install_path/jruby-$version"
400
+ rvm_version="${rvm_version:-1.3.1}"
401
+ if [ "$rvm_version" = "1.2.0" -o "$rvm_version" = "1.3.1" ] ; then
402
+ MY_RUBY_HOME="$rvm_install_path/jruby-$rvm_version"
410
403
  GEM_HOME="$HOME/.gem/jruby/1.8"
411
404
  alias ruby_ng="jruby --ng"
412
405
  alias ruby_ng_server="jruby --ng-server"
413
406
  else
414
- rvm-log-fail "Unknown jRuby version: $version"
407
+ rvm-log-fail "Unknown jRuby version: $rvm_version"
415
408
  fi
416
409
  ;;
417
410
 
418
411
  ree)
419
- version=${version-1.8.6}
420
- if [ "$version" = "1.8.6" ] ; then
421
- patchlevel="${3-20090610}"
422
- MY_RUBY_HOME="$install_path/ruby-enterprise-$version-$patchlevel"
412
+ rvm_version=${rvm_version:-1.8.6}
413
+ if [ "$rvm_version" = "1.8.6" ] ; then
414
+ rvm_patchlevel="${3:-20090610}"
415
+ MY_RUBY_HOME="$rvm_install_path/ruby-enterprise-$rvm_version-$rvm_patchlevel"
423
416
  GEM_HOME="$HOME/.gem/ruby-enterprise/1.8"
424
417
  else
425
- rvm-log-fail "Unknown Ruby Enterprise Edition version: $version"
418
+ rvm-log-fail "Unknown Ruby Enterprise Edition version: $rvm_version"
426
419
  fi
427
420
  ;;
428
421
 
429
422
  ruby)
430
- if [ "$version" = "1.8.7" ] ; then
431
- level="${patchlevel-174}"
432
- MY_RUBY_HOME="$install_path/ruby-1.8.7-p$level"
433
- GEM_HOME="$HOME/.gem/ruby/1.8"
434
-
435
- elif [ "$version" = "1.8.6" -o "$version" = "1.8" ] ; then
436
- level="${patchlevel-369}"
437
- MY_RUBY_HOME="$install_path/ruby-1.8.6-p$level"
438
- GEM_HOME="$HOME/.gem/ruby/1.8"
439
-
440
- elif [ "$version" = "1.9.2" ] ; then
441
- level="${patchlevel-review1}"
442
- MY_RUBY_HOME="$install_path/ruby-1.9.2-p$level"
423
+ if [ "$rvm_version" = "1.8.7" ] ; then
424
+ level="${rvm_patchlevel:-174}"
425
+ MY_RUBY_HOME="$rvm_install_path/ruby-1.8.7-p$level"
426
+ GEM_HOME="$HOME/.gem/ruby/1.8.7"
427
+
428
+ elif [ "$rvm_version" = "1.8.6" -o "$rvm_version" = "1.8" ] ; then
429
+ level="${rvm_patchlevel:-369}"
430
+ MY_RUBY_HOME="$rvm_install_path/ruby-1.8.6-p$level"
431
+ GEM_HOME="$HOME/.gem/ruby/1.8.6"
432
+
433
+ elif [ "$rvm_version" = "1.9.2" ] ; then
434
+ level="${rvm_patchlevel:-review1}"
435
+ MY_RUBY_HOME="$rvm_install_path/ruby-1.9.2-p$level"
443
436
  GEM_HOME="$HOME/.gem/ruby/1.9.2"
444
437
 
445
- elif [ "$version" = "1.9.1" -o "$version" = "1.9" ] ; then
446
- level="${patchlevel-243}"
447
- MY_RUBY_HOME="$install_path/ruby-1.9.1-p$level"
438
+ elif [ "$rvm_version" = "1.9.1" -o "$rvm_version" = "1.9" ] ; then
439
+ level="${rvm_patchlevel:-243}"
440
+ MY_RUBY_HOME="$rvm_install_path/ruby-1.9.1-p$level"
448
441
  GEM_HOME="$HOME/.gem/ruby/1.9.1"
449
442
 
450
443
  else
451
- rvm-log-fail "Unknown ruby version: $version"
444
+ rvm-log-fail "Unknown ruby version: $rvm_version"
452
445
  fi
453
446
  ;;
454
447
 
455
448
  *)
456
- rvm-log-fail "Ruby implementation '$implementation' is not known."
449
+ rvm-log-fail "Ruby implementation '$rvm_implementation' is not known."
457
450
 
458
451
  esac
459
452
 
460
453
  # Now actually use it.
461
- if [ ! "$implementation" = "default" ] ; then
454
+ if [ ! "$rvm_implementation" = "default" ] ; then
462
455
  # Install if not installed
463
456
  if [ ! -d $MY_RUBY_HOME ] ; then
464
- rvm-log-warn "$implementation $version is not installed."
465
- rvm-install-ruby $implementation $version $level
457
+ rvm-log-warn "$rvm_implementation $rvm_version is not installed."
458
+ rvm-install-ruby $rvm_implementation $rvm_version $level
466
459
  fi
467
460
 
468
461
  # Set as 'current'
469
462
  RUBY_VERSION="$($MY_RUBY_HOME/bin/ruby -v | sed 's/^\(.*\) (.*$/\1/')"
470
463
  export GEM_HOME MY_RUBY_HOME RUBY_VERSION
471
464
 
472
- echo "PATH=$MY_RUBY_HOME/bin:$GEM_HOME/bin:$default_path ; export PATH" > $install_path/current
465
+ echo "PATH=$MY_RUBY_HOME/bin:$GEM_HOME/bin:$default_path ; export PATH" > $rvm_install_path/current
473
466
  for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do
474
467
  eval "export $variable"
475
468
  eval value=\$${variable}
476
- echo "${variable}='$value' ; export ${variable}" >> $install_path/current
469
+ echo "${variable}='$value' ; export ${variable}" >> $rvm_install_path/current
477
470
  done
478
471
  fi
479
472
 
480
- rvm-log-info "Switching to $implementation $version $patchlevel ...\n"
473
+ rvm-log-info "Switching to $rvm_implementation $rvm_version $rvm_patchlevel ...\n"
481
474
  if [ ! -z "$BASH_VERSION" ] ; then
482
475
  exec bash -l
483
476
  elif [ ! -z "$ZSH_VERSION" ] ; then
@@ -489,29 +482,24 @@ function rvm-use {
489
482
  }
490
483
 
491
484
  function rvm-symlinks {
492
- mkdir -p ${install_path}/bin
493
- for release in `ls $install_path | grep 'ruby-'` ; do
485
+
486
+ mkdir -p ${rvm_install_path}/bin
487
+ for release in `ls $rvm_install_path | grep 'ruby-'` ; do
494
488
  for binary in ruby irb gem rdoc ri erb ; do
495
- if [ -x $install_path/$release/bin/$binary ] ; then
496
- ln -fs $install_path/$release/bin/$binary $install_path/bin/$binary-${release#ruby-}
489
+ if [ -x $rvm_install_path/$release/bin/$binary ] ; then
490
+ ln -fs $rvm_install_path/$release/bin/$binary $rvm_install_path/bin/$binary-${release#ruby-}
497
491
  fi
498
492
  done
499
493
  done
494
+
500
495
  }
501
496
 
502
497
  function rvm-list {
503
498
 
504
- echo -e "\nruby:"
505
- ls -l $install_path/ | awk '/ ruby-[1-2].*/ { print " - " $NF }'
506
- echo
507
- echo "jruby:"
508
- ls -l $install_path/ | awk '/jruby-.*/ { print " - " $NF }'
509
- echo
510
- echo "ree:"
511
- ls $install_path/ | awk '/ruby-enterprise-.*/ { print " - " $NF }'
512
- echo
513
- echo "default:"
514
- echo " - system (`$default_system_ruby -v`)"
499
+ echo -e "\nruby:\n$(ls -l $rvm_install_path/ | awk '/ ruby-[1-2].*/ { print " - " $NF }')\n"
500
+ echo -e "jruby:\n$(ls -l $rvm_install_path/ | awk '/jruby-.*/ { print " - " $NF }')\n"
501
+ echo -e "ree:\n$(ls $rvm_install_path/ | awk '/ruby-enterprise-.*/ { print " - " $NF }')\n"
502
+ echo -e "system:\n - ($($default_system_ruby -v))\n"
515
503
 
516
504
  }
517
505
 
@@ -521,7 +509,7 @@ function rvm-reset {
521
509
  for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do
522
510
  unset $variable
523
511
  done
524
- rm -f $install_path/default* $install_path/current
512
+ rm -f $rvm_install_path/default* $rvm_install_path/current
525
513
  if [ ! -z "$BASH_VERSION" ] ; then
526
514
  exec bash -l
527
515
  elif [ ! -z "$ZSH_VERSION" ] ; then
@@ -529,29 +517,29 @@ function rvm-reset {
529
517
  else
530
518
  rvm-log-fail "Your shell is not supported bash and zsh are currently supported."
531
519
  fi
532
-
520
+
533
521
  }
534
-
522
+
535
523
  function rvm-gem-dir {
536
524
 
537
- implementation=${1-$implementation}
538
- if [ "$implementation" = "" ] ; then implementation="current" ; fi
525
+ rvm_implementation=${1:-$rvm_implementation}
526
+ if [ -z "$rvm_implementation" ] ; then rvm_implementation="current" ; fi
539
527
 
540
- case "$implementation" in
528
+ case "$rvm_implementation" in
541
529
  jruby) GEM_HOME="$HOME/.gem/jruby/1.8" ;;
542
530
  ree) GEM_HOME="$HOME/.gem/ruby-enterprise/1.8" ;;
543
531
  ruby)
544
- if [ "${2-$version}" = "1.8" -o "${2-$version}" = "1.8.6" ] ; then
532
+ if [ "${2:-$rvm_version}" = "1.8" -o "${2:-$rvm_version}" = "1.8.6" ] ; then
545
533
  GEM_HOME="$HOME/.gem/ruby/1.8"
546
534
 
547
- elif [ "${2-$version}" = "1.9.2" ] ; then
535
+ elif [ "${2:-$rvm_version}" = "1.9.2" ] ; then
548
536
  GEM_HOME="$HOME/.gem/ruby/1.9.2"
549
537
 
550
- elif [ "${2-$version}" = "1.9" -o "${2-$version}" = "1.9.1" ] ; then
538
+ elif [ "${2:-$rvm_version}" = "1.9" -o "${2:-$rvm_version}" = "1.9.1" ] ; then
551
539
  GEM_HOME="$HOME/.gem/ruby/1.9.1"
552
540
 
553
541
  else
554
- rvm-log-fail "Unknown Version: ${2-$version}"
542
+ rvm-log-fail "Unknown Version: ${2:-$rvm_version}"
555
543
  fi
556
544
  ;;
557
545
  current)
@@ -561,56 +549,56 @@ function rvm-gem-dir {
561
549
  GEM_HOME=$default_system_gem_path
562
550
  ;;
563
551
  user)
564
- GEM_HOME=$default_gem_path
552
+ GEM_HOME=$default_user_gem_path
565
553
  ;;
566
554
  *)
567
- rvm-log-fail "Ruby implementation '$implementation' is not known."
555
+ rvm-log-fail "Ruby implementation '$rvm_implementation' is not known."
568
556
  esac
569
557
 
570
558
  if [ -d $GEM_HOME ] ; then
571
559
  echo $GEM_HOME && cd $GEM_HOME
572
560
  else
573
- rvm-log-fail "$implementation $version GEM directory does not exist."
561
+ rvm-log-fail "$rvm_implementation $rvm_version GEM directory does not exist."
574
562
  fi
575
563
 
576
564
  }
577
565
 
578
566
  function rvm-src-dir {
579
- case "${1-$implementation}" in
567
+ case "${1:-$rvm_implementation}" in
580
568
 
581
569
  jruby)
582
- version=${version-1.3.1}
583
- if [ "${2-$version}" = "1.2.0" -o "${2-$version}" = "1.3.1" ] ; then
584
- src_dir="$source_path/$implementation-$version"
570
+ rvm_version=${rvm_version:-1.3.1}
571
+ if [ "${2:-$rvm_version}" = "1.2.0" -o "${2:-$rvm_version}" = "1.3.1" ] ; then
572
+ src_dir="$rvm_source_path/$rvm_implementation-$rvm_version"
585
573
  else
586
- rvm-log-fail "Unknown jRuby version: $version"
574
+ rvm-log-fail "Unknown jRuby version: $rvm_version"
587
575
  fi
588
576
  ;;
589
577
 
590
578
  ree)
591
- version=${version-1.8.6}
592
- if [ "${2-$version}" = "1.8.6" -o "${2-$version}" = "1.8" ] ; then
593
- src_dir="$source_path/ruby-enterprise-${2-$version}-"${3-20090610}""
579
+ rvm_version=${rvm_version:-1.8.6}
580
+ if [ "${2:-$rvm_version}" = "1.8.6" -o "${2:-$rvm_version}" = "1.8" ] ; then
581
+ src_dir="$rvm_source_path/ruby-enterprise-${2:-$rvm_version}-"${3:-20090610}""
594
582
  else
595
- rvm-log-fail "Unknown Ruby Enterprise Edition version: ${2-$version}"
583
+ rvm-log-fail "Unknown Ruby Enterprise Edition version: ${2:-$rvm_version}"
596
584
  fi
597
585
  ;;
598
586
 
599
587
  ruby)
600
- if [ "${2-$version}" = "1.8.7" ] ; then
601
- src_dir="$source_path/ruby-1.8.7-p${patchlevel-174}"
588
+ if [ "${2:-$rvm_version}" = "1.8.7" ] ; then
589
+ src_dir="$rvm_source_path/ruby-1.8.7-p${rvm_patchlevel:-174}"
602
590
 
603
- elif [ "${2-$version}" = "1.8" -o "${2-$version}" = "1.8.6" ] ; then
604
- src_dir="$source_path/ruby-1.8.6-p${patchlevel-369}"
591
+ elif [ "${2:-$rvm_version}" = "1.8" -o "${2:-$rvm_version}" = "1.8.6" ] ; then
592
+ src_dir="$rvm_source_path/ruby-1.8.6-p${rvm_patchlevel:-369}"
605
593
 
606
- elif [ "${2-$version}" = "1.9.2" ] ; then
607
- src_dir="$source_path/ruby-1.9.2-p${patchlevel-review1}"
594
+ elif [ "${2:-$rvm_version}" = "1.9.2" ] ; then
595
+ src_dir="$rvm_source_path/ruby-1.9.2-p${rvm_patchlevel:-review1}"
608
596
 
609
- elif [ "${2-$version}" = "1.9" -o "${2-$version}" = "1.9.1" ] ; then
610
- src_dir="$source_path/ruby-1.9.1-p${patchlevel-243}"
597
+ elif [ "${2:-$rvm_version}" = "1.9" -o "${2:-$rvm_version}" = "1.9.1" ] ; then
598
+ src_dir="$rvm_source_path/ruby-1.9.1-p${rvm_patchlevel:-243}"
611
599
 
612
600
  else
613
- rvm-log-fail "unknown Ruby version: ${2-$version}"
601
+ rvm-log-fail "unknown Ruby version: ${2:-$rvm_version}"
614
602
  fi
615
603
  ;;
616
604
 
@@ -619,14 +607,14 @@ function rvm-src-dir {
619
607
  ;;
620
608
 
621
609
  *)
622
- rvm-log-fail "Ruby implementation '$implementation' is not known."
610
+ rvm-log-fail "Ruby implementation '$rvm_implementation' is not known."
623
611
  return 1
624
612
  esac
625
613
 
626
614
  if [ -d $src_dir ] ; then
627
615
  cd $src_dir
628
616
  else
629
- rvm-log-fail "$implementation $version source directory does not exist."
617
+ rvm-log-fail "$rvm_implementation $rvm_version source directory does not exist."
630
618
  fi
631
619
 
632
620
  }
@@ -635,11 +623,11 @@ function rvm-src-dir {
635
623
  function rvm-gem-dup {
636
624
 
637
625
  if [ "$1" = "default" ] ; then
638
- gem_dir="$default_gem_path"
626
+ gem_dir="$default_user_gem_path"
639
627
  elif [ "$1" = "system" ] ; then
640
628
  gem_dir="$default_system_gem_path"
641
629
  else
642
- gem_dir=${1-$default_gem_path} # TODO: check for and remove trailing /gems
630
+ gem_dir=${1:-$default_user_gem_path} # TODO: check for and remove trailing /gems
643
631
  fi
644
632
 
645
633
  if [ ! -z "$gem_dir" ] ; then
@@ -653,172 +641,188 @@ function rvm-gem-dup {
653
641
  fi
654
642
  done
655
643
  else
656
- rvm-log-fail "Unknown $implementation version: $version"
644
+ rvm-log-fail "Unknown $rvm_implementation version: $rvm_version"
657
645
  fi
658
646
 
659
647
  }
660
648
 
661
- function rvm-version { echo "rvm $rvm_version ($rvm_updated) [$rvm_website]" ; }
649
+ function rvm-version { echo "rvm $rvm_meta_version ($rvm_meta_updated) [$rvm_meta_website]" ; }
662
650
 
663
651
  function rvm {
664
652
 
665
653
  # Cleanup, aisle 3
666
- for variable in action implementation patchlevel version source_path install_path manager debug prefix_path ; do
667
- eval "unset $variable"
668
- done
669
-
654
+ for variable in rvm_action rvm_implementation rvm_patchlevel rvm_version rvm_source_path rvm_install_path rvm_debug rvm_prefix_path rvm_package_name; do
655
+ eval "unset $variable"
656
+ done ; unset variable
657
+
658
+ # NOW load defaults settings. TODO: root user loads /etc/rvmrc
659
+ if [ -f ~/.rvmrc ] ; then source ~/.rvmrc ; fi
660
+
670
661
  while [ $# -gt 0 ] ; do
671
- token="$1" ; shift
672
- case "$token" in
673
- install|uninstall|use|path|info|setup|version|srcdir|list|symlinks|reset|debug)
674
- action=$token
662
+ rvm_token="$1" ; shift
663
+ case "$rvm_token" in
664
+ install|uninstall|use|path|info|setup|version|srcdir|list|symlinks|reset|debug|reload)
665
+ rvm_action=$rvm_token
675
666
  ;;
676
667
 
677
668
  ruby|jruby|ree|default|all)
678
- implementation="$token"
679
- action="${action-use}"
669
+ rvm_implementation="$rvm_token"
670
+ rvm_action="${rvm_action:-use}"
680
671
  ;;
681
672
 
682
673
  gemdir)
683
- action=$token
674
+ rvm_action=$rvm_token
684
675
  if [ "$1" = "system" ] ; then
685
- implementation="system" ; shift
676
+ rvm_implementation="system" ; shift
686
677
  fi
687
- if [ "$1" = "user" ] ; then
688
- implementation="user" ; shift
678
+ if [ "$1" = "user" ] ; then
679
+ rvm_implementation="user" ; shift
689
680
  fi
690
681
 
691
- implementation="${implementation-current}"
682
+ rvm_implementation="${rvm_implementation:-current}"
692
683
  ;;
693
684
 
694
685
  gemdup)
695
- action=$token
686
+ rvm_action=$rvm_token
696
687
  if [ -z "$1" ] ; then
697
- implementaiton="default"
688
+ rvm_implementation="default"
698
689
  elif [ "$1" = "system" ] ; then
699
- implementation=$1 ; shift
690
+ rvm_implementation=$1 ; shift
700
691
  elif [ "$1" = "default" ] ; then
701
- implementation=$1 ; shift
692
+ rvm_implementation=$1 ; shift
702
693
  else
703
- implementation=$1 ; shift
704
- version=$2 ; shift
694
+ rvm_implementation=$1 ; shift
695
+ rvm_version=$2 ; shift
705
696
  fi
706
697
  ;;
707
698
 
708
699
  1.8|1.8.6|1.8.7|1.9|1.9.1|1.9.2|1.2.0|1.3.1)
709
- version="$token"
710
- action="${action-use}"
700
+ rvm_version="$rvm_token"
701
+ rvm_action="${rvm_action:-use}"
711
702
  ;;
712
703
 
713
- -v|--version)
714
- if [ -z "$1" ] ; then
715
- action="version"
716
- else
717
- version="$1"
704
+ -v|--version)
705
+ if [ -z "$1" ] ; then
706
+ rvm_action="version"
707
+ else
708
+ rvm_version="$1"
718
709
  fi
719
710
  shift
720
711
  ;;
721
712
 
722
- -l|--level) patchlevel="$1" ; shift ;;
723
- -p|--prefix) install_path="$1" ; shift ;;
724
- -s|--source) source_path="$1" ; shift ;; # Undocumented / untested "feature"
725
- -c|--configure) configure="$1" ; shift ;;
726
- -d|--debug) debug=1 ;;
713
+ -l|--level) rvm_patchlevel="$1" ; shift ;;
714
+ -p|--prefix) rvm_prefix_path="$1" ; shift ;;
715
+ -b|--bin) rvm_bin_path="$1" ; shift ;; # Undocumented / untested "feature"
716
+ -s|--source) rvm_source_path="$1" ; shift ;; # Undocumented / untested "feature"
717
+ -a|--archive) rvm_archives_path="$1" ; shift ;;
718
+ -c|--configure) configure="$1" ; shift ;;
719
+ -n|--nice) niceness="$1" ; shift ;;
720
+ -d|--debug) rvm_debug=1 ;;
727
721
  *) rvm-usage ; return 1
728
- esac
729
- done
730
-
731
- curl=`which curl`
722
+ esac
723
+ done
724
+
725
+ if [ "$rvm_debug" = "1" ] ; then set -x ; fi
726
+
727
+ rvm_curl=`which curl`
732
728
  if [ $? -ne 0 ] ; then
733
729
  rvm-log-fail "rvm expects that curl is available, which curl shows no curl :("
734
730
  else
735
- curl="$curl -O -L -s"
731
+ rvm_curl="$rvm_curl -O -L -s"
736
732
  fi
737
733
 
738
- if [ -z "$implementation" -a -z "$version" ] ; then
739
- implementation="default"
734
+ if [ -z "$rvm_implementation" -a -z "$rvm_version" ] ; then
735
+ rvm_implementation="default"
740
736
  else
741
- implementation=${implementation-'ruby'}
737
+ rvm_implementation=${rvm_implementation:-ruby}
742
738
  fi
743
739
 
740
+ niceness=${niceness:-0}
741
+
744
742
  # TODO: Sanitize user input, ensure that there is a / a the end...
745
- if [ "`whoami`" = "root" ] ; then
743
+ if [ "`whoami`" = "root" ] ; then
746
744
  rvm-log-fail "root user support is not yet implemented."
747
- #prefix_path=${prefix-/usr/local/}
745
+ #rvm_prefix_path=${rvm_prefix_path:-/usr/local/}
746
+ else
747
+ rvm_prefix_path=${rvm_prefix_path:-"$HOME/."}
748
+ fi
749
+ if [ "${rvm_prefix_path#${rvm_prefix_path%?}}" = '.' -o "${rvm_prefix_path#${rvm_prefix_path%?}}" = '/' ] ; then
750
+ rvm_install_path="${rvm_prefix_path}rvm"
748
751
  else
749
- prefix_path=${prefix-$HOME/.}
752
+ rvm_install_path="${rvm_prefix_path}/rvm"
750
753
  fi
751
- source_path="${source_path-"${prefix_path}rvm/src"}"
752
- install_path="${prefix_path}rvm"
753
-
754
- mkdir -p $source_path $install_path/bin
754
+ rvm_archives_path="${rvm_archives_path:-"${rvm_install_path}/archives"}"
755
+ rvm_source_path="${rvm_source_path:-"${rvm_install_path}/src"}"
756
+ rvm_log_path=${rvm_log_path:-"${rvm_install_path}/log"}
757
+ rvm_bin_path=${rvm_bin_path:-"${rvm_install_path}/bin"}
755
758
 
756
- if [ ! -f $install_path/default ] ; then
759
+ PATH=$rvm_bin_path:$PATH ; export PATH
760
+
761
+ mkdir -p $rvm_source_path $rvm_install_path/bin $rvm_archives_path
762
+
763
+ if [ ! -f $rvm_install_path/default ] ; then
757
764
  for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME PATH ; do
758
765
  eval "export $variable"
759
766
  eval value=\$${variable}
760
- echo "${variable}='$value' ; export ${variable}" >> $install_path/default
767
+ echo "${variable}='$value' ; export ${variable}" >> $rvm_install_path/default
761
768
  done
762
769
  fi
763
770
 
764
- if [ -s $install_path/default_path ] ; then
765
- default_path=`cat $install_path/default_path`
771
+ if [ -s $rvm_install_path/default_path ] ; then
772
+ default_path=`cat $rvm_install_path/default_path`
766
773
  else
767
- echo $PATH > $install_path/default_path
774
+ echo $PATH > $rvm_install_path/default_path
768
775
  default_path=$PATH
769
776
  fi
770
777
 
771
- # default (user) gem path
772
- if [ -s $install_path/default_gem_path ] ; then
773
- default_gem_path=`cat $install_path/default_gem_path`
778
+ if [ -s $rvm_install_path/default_user_gem_path ] ; then
779
+ default_user_gem_path=`cat $rvm_install_path/default_user_gem_path`
774
780
  else
775
- ruby -r rubygems -e "puts Gem::default_path.compact.first" > $install_path/default_gem_path
781
+ ruby -r rubygems -e "puts Gem::default_path.compact.first" > $rvm_install_path/default_user_gem_path
776
782
  fi
777
783
 
778
- # system gem path
779
- if [ -s $install_path/default_system_gem_path ] ; then
780
- default_system_gem_path=`cat $install_path/default_system_gem_path`
784
+ if [ -s $rvm_install_path/default_system_gem_path ] ; then
785
+ default_system_gem_path=`cat $rvm_install_path/default_system_gem_path`
781
786
  else
782
- ruby -r rubygems -e "puts Gem::default_path.compact[1] || Gem::default_path.compact.first" > $install_path/default_system_gem_path
787
+ ruby -r rubygems -e "puts Gem::default_path.compact[1] || Gem::default_path.compact.first" > $rvm_install_path/default_system_gem_path
783
788
  fi
784
789
 
785
- # system ruby version
786
- if [ -s $install_path/default_system_ruby ] ; then
787
- default_system_ruby=`cat $install_path/default_system_ruby`
790
+ if [ -s $rvm_install_path/default_system_ruby ] ; then
791
+ default_system_ruby=`cat $rvm_install_path/default_system_ruby`
788
792
  else
789
793
  default_system_ruby=`which ruby`
790
- echo $default_system_ruby > $install_path/default_system_ruby
794
+ echo $default_system_ruby > $rvm_install_path/default_system_ruby
791
795
  fi
792
796
 
793
- if [ "$debug" = "1" ] ; then set -x ; fi
794
-
795
- case "$action" in
796
- install)
797
- if [ "$implementation" = "all" ] ; then
798
- for implementation in ruby jruby ree ; do
799
- if [ "$implementation" = "ruby" ] ; then
800
- for version in 1.8.6 1.8.7 1.9.1 1.9.2 ; do
801
- rvm-install-ruby $implementation $version $patchlevel
797
+ case "$rvm_action" in
798
+ install)
799
+ if [ "$rvm_implementation" = "all" ] ; then
800
+ for rvm_implementation in ruby jruby ree ; do
801
+ if [ "$rvm_implementation" = "ruby" ] ; then
802
+ for rvm_version in 1.8.6 1.8.7 1.9.1 1.9.2 ; do
803
+ rvm-install-ruby $rvm_implementation $rvm_version
802
804
  done
805
+ unset rvm_version
803
806
  else
804
- rvm-install-ruby $implementation $version $patchlevel
807
+ rvm-install-ruby $rvm_implementation $rvm_version
805
808
  fi
806
809
  done
807
810
  else
808
- rvm-install-ruby $implementation $version $patchlevel
811
+ rvm-install-ruby $rvm_implementation $rvm_version $rvm_patchlevel
809
812
  fi
810
813
  ;;
811
- uninstall) rvm-uninstall $implementation $version $patchlevel ;;
812
- use) rvm-use $implementation $version $patchlevel ;;
813
- list) rvm-list ;;
814
- gemdir) rvm-gem-dir $implementation $version $patchlevel ;;
815
- srcdir) rvm-src-dir $implementation $version $patchlevel ;;
816
- gemdup) rvm-gem-dup $implementation $version $patchlevel ;;
817
- info) rvm-info $implementation $version $patchlevel ;;
818
- symlinks) rvm-symlinks ;;
819
- version) rvm-version ;;
820
- reset) rvm-reset ;;
821
- debug)
814
+ uninstall) rvm-uninstall $rvm_implementation $rvm_version $rvm_patchlevel ;;
815
+ use) rvm-use $rvm_implementation $rvm_version $rvm_patchlevel ;;
816
+ list) rvm-list ;;
817
+ gemdir) rvm-gem-dir $rvm_implementation $rvm_version $rvm_patchlevel ;;
818
+ srcdir) rvm-src-dir $rvm_implementation $rvm_version $rvm_patchlevel ;;
819
+ gemdup) rvm-gem-dup $rvm_implementation $rvm_version $rvm_patchlevel ;;
820
+ info) rvm-info $rvm_implementation $rvm_version $rvm_patchlevel ;;
821
+ symlinks) rvm-symlinks ;;
822
+ version) rvm-version ;;
823
+ reset) rvm-reset ;;
824
+ reload) source ~/.rvm/bin/rvm ;; # TODO: how can we use bin_path here, default file?
825
+ debug)
822
826
  rvm-version
823
827
  rvm-info
824
828
  rvm-log-info "PATH:$(echo $PATH | awk -F":" '{print $1":"$2":"$3":"$4":"$5}')"
@@ -827,19 +831,22 @@ function rvm {
827
831
  rvm-log-info "~/$file: \n$(cat ~/$file| tail -n 5)\n"
828
832
  fi
829
833
  done
830
- rvm-log-info "$install_path/current: \n$(cat $install_path/current)\n"
834
+ rvm-log-info "$rvm_install_path/current: \n$(cat $rvm_install_path/current)\n"
831
835
  return 0
832
836
  ;;
833
- *)
834
- if [ ! -z "$action" ] ; then
835
- rvm-log-fail "unknown action '$action'"
837
+ *)
838
+ if [ ! -z "$rvm_action" ] ; then
839
+ rvm-log-fail "unknown action '$rvm_action'"
836
840
  else
837
- rvm-usage
841
+ rvm-usage
838
842
  fi
839
843
  return 1
840
844
  esac
841
845
 
842
- if [ "$debug" = "1" ] ; then set +x ; fi
846
+ if [ "$rvm_debug" = "1" ] ; then set +x ; unset rvm_debug ; fi
843
847
 
844
848
  }
845
849
 
850
+ # TODO: Make this optional:
851
+ if [ -f ~/.rvm/current ] ; then source ~/.rvm/current ; fi # magic :)
852
+