rvm 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,8 +16,8 @@ if [[ $rvm_pretty_print -eq 0 ]] ; then
16
16
  fi
17
17
 
18
18
  case "$level" in
19
- debug|info|warn) printf "$message\n" ;;
20
- error|fail) printf "$message\n" >&2 ;;
19
+ debug|info|warn) printf "$message\n" ;;
20
+ error|fail) printf "$message\n" >&2 ;;
21
21
  *) printf "$message"
22
22
  esac
23
23
  else
@@ -15,46 +15,68 @@ __rvm_check_for_clang() {
15
15
 
16
16
  # Checks for bison, returns zero iff it is found
17
17
  __rvm_check_for_bison() {
18
+ local result
19
+
18
20
  if [[ ${rvm_head_flag:-0} -gt 0 ]]; then
19
- if ! command -v bison >/dev/null ; then
20
- "$rvm_scripts_path/log" "fail" "\nbison is not available in your path. \nPlease ensure bison is installed before compiling from head.\n"
21
- return 1
21
+ command -v bison > /dev/null
22
+ result=$?
23
+ if [[ $? -gt 0 ]] ; then
24
+ "$rvm_scripts_path/log" "fail" \
25
+ "\nbison is not available in your path. \nPlease ensure bison is installed before compiling from head.\n"
22
26
  fi
23
27
  fi
28
+
29
+ return $result
24
30
  }
25
31
 
26
32
  # Emits a number of patches to STDOUT, each on a new name
27
33
  # Expands patchsets etc.
28
34
  __rvm_current_patch_names() {
29
35
  # TODO: Lookup default patches on rvm_ruby_string heirarchy.
30
- local separator="%"
31
- local patches="${rvm_patch_names:-""} default"
36
+ local separator patches level name
37
+
38
+ separator="%"
39
+ patches="${rvm_patch_names:-""} default"
32
40
 
33
41
  for patch_name in $(echo ${patches//,/ }); do
34
- local level=1
35
- local name="$patch_name"
42
+
43
+ level=1
44
+ name="$patch_name"
45
+
36
46
  if echo "$name" | grep -q "$separator"; then
37
47
  level="${name/*${separator}/}"
38
48
  name="${name//${separator}*/}"
39
49
  fi
50
+
40
51
  local expanded_name="$(__rvm_expand_patch_name "$name")"
52
+
41
53
  echo "${expanded_name}${separator}${level}"
54
+
42
55
  done
56
+
57
+ return 0
43
58
  }
44
59
 
45
60
  __rvm_apply_patches() {
46
- local patch_result=0
47
- local patch_level_separator="%"
48
- local patch_fuzziness="25"
49
- local patch_level=1
50
- local source_directory="${1:-"$rvm_ruby_src_path"}"
61
+
62
+ local patches patch_name result patch_level_separator patch_fuzziness patch_level source_directory full_patch_path
63
+
64
+ result=0
65
+ patch_level_separator="%"
66
+ patch_fuzziness="25"
67
+ patch_level=1
68
+ source_directory="${1:-"$rvm_ruby_src_path"}"
69
+
51
70
  (
52
71
  builtin cd "$source_directory"
53
72
 
54
- patches="$(__rvm_current_patch_names | __rvm_strip)"
55
- for patch_name in $(echo $patches); do
73
+ patches=($(__rvm_current_patch_names))
74
+
75
+ for patch_name in "${patches[@]}" ; do
76
+
56
77
  # If set, extract the patch level from the patch name.
57
78
  patch_level=1
79
+
58
80
  if echo "$patch_name" | \grep -q "$patch_level_separator"; then
59
81
  patch_level=${patch_name//*${patch_level_separator}/}
60
82
  patch_name="${patch_name//${patch_level_separator}*/}"
@@ -66,112 +88,164 @@ __rvm_apply_patches() {
66
88
  if [[ -n "${full_patch_path:-""}" ]]; then
67
89
 
68
90
  if [[ -f "$full_patch_path" ]] ; then
91
+
69
92
  __rvm_run "patch.apply.${patch_name/*\/}" "patch -F$patch_fuzziness -p$patch_level -f <\"$full_patch_path\"" "Applying patch '$patch_name' (located at $full_patch_path)"
70
- # Detect failed patches
71
- [[ $? -gt 0 ]] && patch_result=1
93
+
94
+ [[ $? -gt 0 ]] && result=1 # Detect failed patches
72
95
  fi
96
+
73
97
  else
74
- "$rvm_scripts_path/log" "warn" "Patch '$patch_name' not found."
75
- patch_result=1
98
+ "$rvm_scripts_path/log" "warn" \
99
+ "Patch '$patch_name' not found."
100
+ result=1
76
101
  fi
77
102
  done
78
103
  )
79
- unset patch_name full_patch_path patch_level
80
- return $patch_result
104
+
105
+ return $result
81
106
  }
82
107
 
83
108
  __rvm_install_source() {
109
+
110
+ local directory configure_parameters db_configure_flags
111
+
84
112
  [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] && __rvm_select
85
113
 
86
- if [[ "${rvm_ruby_string:-""}" =~ "-head" ]] ; then
87
- # Ensure we have a base ruby.
88
- __rvm_ensure_has_18_compat_ruby || return 1
89
- fi
114
+ case ${rvm_ruby_string:-""} in
115
+ *-head) __rvm_ensure_has_18_compat_ruby || return 1 ;;
116
+ esac
90
117
 
91
118
  "$rvm_scripts_path/log" "info" "\nInstalling Ruby from source to: $rvm_ruby_home, this may take a while depending on your cpu(s)...\n"
92
119
 
93
120
  builtin cd "$rvm_src_path"
94
121
 
95
122
  if [[ ${rvm_force_flag:-0} -eq 1 ]] ; then
123
+
96
124
  for directory in "$rvm_ruby_home" "$rvm_ruby_src_path" ; do
97
- [[ -d "$directory" ]] && rm -rf "$directory"
125
+
126
+ if [[ -d "$directory" ]] ; then
127
+ rm -rf "$directory"
128
+ fi
129
+
98
130
  done
99
131
  fi
100
132
 
101
133
  result=0
134
+
102
135
  __rvm_fetch_ruby
103
- result=$? ; if [[ "$result" -gt 0 ]] ; then
104
- "$rvm_scripts_path/log" "error" "There has been an error fetching the ruby interpreter. Aborting the installation." ; return $result
136
+ result=$?
137
+
138
+ if [[ "$result" -gt 0 ]] ; then
139
+ "$rvm_scripts_path/log" "error" \
140
+ "There has been an error fetching the ruby interpreter. Aborting the installation."
141
+ return $result
105
142
  fi
106
143
 
107
144
  builtin cd "$rvm_ruby_src_path"
108
145
 
109
146
  result=$? ; if [[ "$result" -gt 0 ]] ; then
110
- "$rvm_scripts_path/log" "error" "There has been an error, source directory is missing. Did the download or extraction fail? Aborting the installation." ; return $result
147
+ "$rvm_scripts_path/log" "error" \
148
+ "Source directory is missing. Did the download or extraction fail? Aborting the installation."
149
+ return $result
111
150
  fi
112
151
 
113
152
  if [[ -d "${rvm_path}/usr" ]] ; then
114
153
  export PATH="${rvm_path}/usr/bin:${PATH}"
154
+
115
155
  builtin hash -r
116
156
  fi
117
157
 
118
158
  __rvm_apply_patches
119
159
  result="$?"
160
+
120
161
  if [[ "$result" -gt 0 ]]; then
121
- "$rvm_scripts_path/log" "fail" "There has been an error applying the specified patches. Aborting the installation."
162
+ "$rvm_scripts_path/log" "fail" \
163
+ "There has been an error applying the specified patches. Aborting the installation."
122
164
  return $result
123
165
  fi
124
166
 
125
- if [[ -z "${rvm_ruby_configure:-""}" ]] && [[ ! -s "$rvm_ruby_src_path/configure" ]] ; then
167
+ if [[ -z "${rvm_ruby_configure:-""}" && ! -s "$rvm_ruby_src_path/configure" ]] ; then
168
+
126
169
  if command -v autoconf > /dev/null ; then
170
+
127
171
  __rvm_run "autoconf" "autoconf" "Running autoconf"
172
+
128
173
  else
129
- result=$? ; "$rvm_scripts_path/log" "fail" "rvm requires autoconf to install the selected ruby interpreter however autoconf was not found in the PATH." ; return $result
174
+ "$rvm_scripts_path/log" "fail" \
175
+ "rvm requires autoconf to install the selected ruby interpreter however autoconf was not found in the PATH."
176
+ return 1
130
177
  fi
131
178
  fi
132
179
 
133
180
  if [[ -n "${rvm_ruby_configure:-""}" ]] ; then
181
+
134
182
  __rvm_run "configure" "$rvm_ruby_configure"
135
- result=$? ; if [[ "$result" -gt 0 ]] ; then
136
- "$rvm_scripts_path/log" "error" "There has been an error while configuring. Aborting the installation." ; return $result
183
+ result=$?
184
+
185
+ if [[ "$result" -gt 0 ]] ; then
186
+ "$rvm_scripts_path/log" "error" \
187
+ "There has been an error while configuring. Aborting the installation."
188
+ return $result
137
189
  fi
190
+
138
191
  elif [[ -s ./configure ]] ; then
192
+
139
193
  # REE stores configure flags differently for head vs. the distributed release.
140
- if [[ "ree" != "$rvm_ruby_interpreter" ]]; then
194
+ if [[ "ree" != "${rvm_ruby_interpreter:-""}" ]]; then
141
195
  __rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
142
196
  fi
143
197
 
144
198
  # On 1.9.2, we manually set the --with-baseruby option
145
199
  # to point to an expanded path.
146
200
  if [[ "${rvm_ruby_string:-""}" = "ruby-1.9.2-head" ]] ; then
201
+
147
202
  local compatible_baseruby="$rvm_wrappers_path/$(__rvm_18_compat_ruby)/ruby"
203
+
148
204
  if [[ -x "$compatible_baseruby" ]] ; then
149
205
  configure_parameters="--with-baseruby=$compatible_baseruby"
150
206
  fi
151
207
  fi
152
208
 
153
- local configure_command="./configure --prefix=$rvm_ruby_home ${db_configure_flags:-""} ${rvm_ruby_configure_flags:-""} ${configure_parameters:-""}"
209
+ local configure_command="./configure --prefix=$rvm_ruby_home ${db_configure_flags:-""} ${rvm_configure_flags:-""} ${configure_parameters:-""}"
210
+
154
211
  __rvm_run "configure" "$configure_command" "#configuring $rvm_ruby_string"
155
- unset configure_parameters db_configure_flags
156
- result=$? ; if [[ "$result" -gt 0 ]] ; then
157
- "$rvm_scripts_path/log" "error" "There has been an error while running configure. Aborting the installation." ; return $result
212
+ result=$?
213
+
214
+ if [[ "$result" -gt 0 ]] ; then
215
+ "$rvm_scripts_path/log" "error" \
216
+ "There has been an error while running configure. Aborting the installation."
217
+ return $result
158
218
  fi
219
+
159
220
  else
160
- "$rvm_scripts_path/log" "error" "Skipping configure step, 'configure' does not exist, did autoconf not run successfully?"
221
+ "$rvm_scripts_path/log" "error" \
222
+ "Skipping configure step, 'configure' does not exist, did autoconf not run successfully?"
161
223
  fi
162
224
 
163
225
  rvm_ruby_make=${rvm_ruby_make:-"make"}
226
+
164
227
  __rvm_run "make" "$rvm_ruby_make ${rvm_make_flags:-""}" "#compiling $rvm_ruby_string"
165
- result=$? ; if [[ "$result" -gt 0 ]] ; then
166
- "$rvm_scripts_path/log" "error" "There has been an error while running make. Aborting the installation." ; return $result
228
+ result=$?
229
+
230
+ if [[ "$result" -gt 0 ]] ; then
231
+ "$rvm_scripts_path/log" "error" \
232
+ "There has been an error while running make. Aborting the installation."
233
+ return $result
167
234
  fi
168
235
 
169
- if [[ -d .ext/rdoc ]] ; then \rm -rf .ext/rdoc ; fi
236
+ if [[ -d .ext/rdoc ]] ; then
237
+ rm -rf .ext/rdoc
238
+ fi
170
239
 
171
240
  rvm_ruby_make_install=${rvm_ruby_make_install:-"make install"}
241
+
172
242
  __rvm_run "install" "$rvm_ruby_make_install" "#installing $rvm_ruby_string"
173
- result=$? ; if [[ "$result" -gt 0 ]] ; then
174
- "$rvm_scripts_path/log" "error" "There has been an error while running make install. Aborting the installation." ; return $result
243
+ result=$?
244
+
245
+ if [[ "$result" -gt 0 ]] ; then
246
+ "$rvm_scripts_path/log" "error" \
247
+ "There has been an error while running make install. Aborting the installation."
248
+ return $result
175
249
  fi
176
250
 
177
251
  export GEM_HOME="$rvm_ruby_gem_home"
@@ -179,15 +253,23 @@ __rvm_install_source() {
179
253
  export BUNDLE_PATH="$rvm_ruby_gem_home"
180
254
 
181
255
  __rvm_rubygems_setup
256
+
182
257
  __rvm_bin_script
258
+
183
259
  __rvm_run "chmod.bin" "chmod +x $rvm_ruby_home/bin/*"
260
+
184
261
  __rvm_post_install
185
262
 
186
- "$rvm_scripts_path/log" "info" "#complete install of $rvm_ruby_string"
263
+ "$rvm_scripts_path/log" "info" \
264
+ "#complete install of $rvm_ruby_string"
265
+
266
+ return 0
187
267
  }
188
268
 
189
269
  __rvm_install_ruby() {
190
270
 
271
+ local result
272
+
191
273
  if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi
192
274
 
193
275
  if [[ -n "${RUBYOPT:-""}" ]] ; then ruby_options="$RUBYOPT" ; fi
@@ -195,7 +277,8 @@ __rvm_install_ruby() {
195
277
 
196
278
  # Check for clang if the flag is set
197
279
  __rvm_check_for_clang
198
- local result="$?"
280
+ result="$?"
281
+
199
282
  [[ $result -gt 0 ]] && return $result
200
283
 
201
284
  case "$rvm_ruby_interpreter" in
@@ -213,37 +296,65 @@ __rvm_install_ruby() {
213
296
  rvm_ruby_configure=" true "
214
297
  rvm_ruby_make="rake"
215
298
  rvm_ruby_make_install="sudo rake install"
299
+
216
300
  __rvm_db "${rvm_ruby_interpreter}_repo_url" "rvm_ruby_url"
301
+
217
302
  rvm_ruby_repo_url=$rvm_ruby_url
303
+
218
304
  __rvm_install_source $*
219
- result=$? ; if [[ "$result" -gt 0 ]] ; then
220
- "$rvm_scripts_path/log" "error" "There has been an error while trying to install from source. Aborting the installation." ; return $result
305
+ result=$?
306
+
307
+ if [[ "$result" -gt 0 ]] ; then
308
+ "$rvm_scripts_path/log" "error" \
309
+ "There has been an error while trying to install from source. Aborting the installation."
310
+ return $result
221
311
  fi
222
312
 
223
313
  elif [[ "nightly" = "$rvm_ruby_version" ]] ; then
224
314
  macruby_path="/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/bin"
225
315
  # TODO: Separated nightly from head.
316
+
226
317
  "$rvm_scripts_path/log" "info" "Retrieving the latest nightly macruby build..."
318
+
227
319
  "$rvm_scripts_path/fetch" "$rvm_ruby_url"
228
- result=$? ; if [[ "$result" -gt 0 ]] ; then
229
- "$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the source. Aborting the installation." ; return $result
320
+ result=$?
321
+
322
+ if [[ "$result" -gt 0 ]] ; then
323
+ "$rvm_scripts_path/log" "error" \
324
+ "There has been an error while trying to fetch the source. Aborting the installation."
325
+ return $result
230
326
  fi
327
+
231
328
  mv "$rvm_archives_path/macruby_nightly-latest.pkg" "$rvm_archives_path/macruby_nightly.pkg"
329
+
232
330
  __rvm_run "macruby/extract" "sudo /usr/sbin/installer -pkg '$rvm_archives_path/macruby_nightly.pkg' -target '/'"
331
+
233
332
  mkdir -p "$rvm_ruby_home/bin"
234
333
 
235
334
  else
236
335
  macruby_path="/Library/Frameworks/MacRuby.framework/Versions/${rvm_ruby_version}/usr/bin"
336
+
237
337
  # TODO: Separated nightly from head.
238
338
  "$rvm_scripts_path/log" "info" "Retrieving MacRuby ${rvm_ruby_version} ..."
339
+
239
340
  "$rvm_scripts_path/fetch" "$rvm_ruby_url"
240
- result=$? ; if [[ "$result" -gt 0 ]] ; then
241
- "$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the source. Aborting the installation." ; return $result
341
+
342
+ result=$?
343
+
344
+ if [[ "$result" -gt 0 ]] ; then
345
+ "$rvm_scripts_path/log" "error" \
346
+ "There has been an error while trying to fetch the source. Aborting the installation."
347
+ return $result
242
348
  fi
349
+
243
350
  mkdir -p $rvm_ruby_src_path
351
+
244
352
  unzip -o -j "$rvm_archives_path/$rvm_ruby_package_file" "MacRuby ${rvm_ruby_version}/MacRuby ${rvm_ruby_version}.pkg" -d "$rvm_ruby_src_path"
353
+
245
354
  mv "$rvm_ruby_src_path/MacRuby ${rvm_ruby_version}.pkg" "$rvm_ruby_src_path/$rvm_ruby_string.pkg"
355
+
246
356
  __rvm_run "macruby/extract" "sudo /usr/sbin/installer -pkg '$rvm_ruby_src_path/$rvm_ruby_string.pkg' -target '/'"
357
+
247
358
  mkdir -p "$rvm_ruby_home/bin"
248
359
  fi
249
360
 
@@ -263,17 +374,25 @@ RubyWrapper
263
374
  )
264
375
 
265
376
  file_name="$rvm_ruby_home/bin/$binary_name"
266
- rm -f "$file_name"
377
+
378
+ if [[ -f "$file_name" ]] ; then
379
+ rm -f "$file_name"
380
+ fi
381
+
267
382
  echo "$ruby_wrapper" > "$file_name"
268
- if [[ -f "$file_name" ]] ; then chmod +x $file_name ; fi
383
+
384
+ if [[ -f "$file_name" ]] ; then
385
+ chmod +x $file_name
386
+ fi
387
+
269
388
  if [[ "$binary_name" = "ruby" ]] ; then
270
389
  echo "$ruby_wrapper" > "$rvm_bin_path/$rvm_ruby_string"
271
390
  fi
272
- unset file_name ruby_wrapper binary_name files prefix
273
391
  done
274
392
  __rvm_irbrc
275
393
  else
276
- "$rvm_scripts_path/log" "fail" "MacRuby can only be installed on a Darwin OS."
394
+ "$rvm_scripts_path/log" "fail" \
395
+ "MacRuby can only be installed on a Darwin OS."
277
396
  fi
278
397
  ;;
279
398
 
@@ -285,22 +404,34 @@ RubyWrapper
285
404
  "$rvm_scripts_path/log" "info" "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home"
286
405
 
287
406
  builtin cd "$rvm_src_path"
407
+
288
408
  if [[ ${rvm_force_flag:-0} -eq 0 && -d "$rvm_ruby_src_path" && ! -x "$rvm_ruby_src_path/installer" ]] ; then
289
- "$rvm_scripts_path/log" "It appears that the archive has already been extracted. Skipping extract (use --force to force re-download and extract)."
409
+
410
+ "$rvm_scripts_path/log" \
411
+ "It appears that the archive has already been extracted. Skipping extract (use --force to force re-download and extract)."
290
412
 
291
413
  else
292
414
  "$rvm_scripts_path/log" "#fetching $rvm_ruby_package_file"
293
415
 
294
416
  "$rvm_scripts_path/fetch" "$rvm_ruby_url"
295
- result=$? ; if [[ "$result" -gt 0 ]] ; then
296
- "$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the source. Aborting the installation." ; return $result
417
+ result=$?
418
+
419
+ if [[ "$result" -gt 0 ]] ; then
420
+ "$rvm_scripts_path/log" "error" \
421
+ "There has been an error while trying to fetch the source. Aborting the installation."
422
+ return $result
297
423
  fi
298
424
 
299
425
  rm -rf "$rvm_ruby_src_path"
426
+
300
427
  __rvm_run "extract" "gunzip < \"$rvm_archives_path/$rvm_ruby_package_file.$rvm_archive_extension\" | tar xf - -C $rvm_src_path" "#extracting $rvm_ruby_package_file to $rvm_ruby_src_path"
301
428
 
302
- result=$? ; if [[ "$result" -gt 0 ]] ; then
303
- "$rvm_scripts_path/log" "error" "There has been an error while trying to extract the source. Aborting the installation." ; return $result
429
+ result=$?
430
+
431
+ if [[ "$result" -gt 0 ]] ; then
432
+ "$rvm_scripts_path/log" "error" \
433
+ "There has been an error while trying to extract the source. Aborting the installation."
434
+ return $result
304
435
  fi
305
436
 
306
437
  mv "$rvm_src_path/$rvm_ruby_package_file" "$rvm_ruby_src_path"
@@ -308,25 +439,35 @@ RubyWrapper
308
439
 
309
440
  builtin cd "$rvm_ruby_src_path"
310
441
 
442
+ # wait, what? v v v TODO: Investigate line smell.
311
443
  mkdir -p "${rvm_ruby_home}/lib/ruby/gems/1.8/gems"
312
- if [[ -n "$rvm_ruby_configure_flags" ]] ; then
313
- rvm_ruby_configure_flags="${rvm_ruby_configure_flags//--/-c --}"
444
+
445
+ if [[ -n "$rvm_configure_flags" ]] ; then
446
+ rvm_configure_flags="${rvm_configure_flags//--/-c --}"
314
447
  fi
315
448
 
316
- if [[ "Darwin" = "$(uname)" ]] && [[ "1.8.6" = "$rvm_ruby_version" ]] && [[ -z "$rvm_ree_options" ]] ; then
449
+ if [[ "Darwin" = "$(uname)" && "1.8.6" = "$rvm_ruby_version" && -z "$rvm_ree_options" ]] ; then
317
450
  rvm_ree_options="${rvm_ree_options} --no-tcmalloc"
318
451
  fi
319
452
 
320
453
  __rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
321
454
 
322
455
  __rvm_apply_patches "$rvm_ruby_src_path/source"
323
- result=$? ; if [[ "$result" -gt 0 ]] ; then
324
- "$rvm_scripts_path/log" "error" "There has been an error while trying to apply patches to ree. Aborting the installation." ; return $result
456
+ result=$?
457
+
458
+ if [[ "$result" -gt 0 ]] ; then
459
+ "$rvm_scripts_path/log" "error" \
460
+ "There has been an error while trying to apply patches to ree. Aborting the installation."
461
+ return $result
325
462
  fi
326
463
 
327
- __rvm_run "install" "./installer -a $rvm_rubies_path/$rvm_ruby_string $rvm_ree_options $db_configure_flags $rvm_ruby_configure_flags" "#installing $rvm_ruby_string"
328
- result=$? ; if [[ "$result" -gt 0 ]] ; then
329
- "$rvm_scripts_path/log" "error" "There has been an error while trying to run the ree installer. Aborting the installation." ; return $result
464
+ __rvm_run "install" "./installer -a $rvm_rubies_path/$rvm_ruby_string $rvm_ree_options $db_configure_flags $rvm_configure_flags" "#installing $rvm_ruby_string"
465
+ result=$?
466
+
467
+ if [[ "$result" -gt 0 ]] ; then
468
+ "$rvm_scripts_path/log" "error" \
469
+ "There has been an error while trying to run the ree installer. Aborting the installation."
470
+ return $result
330
471
  fi
331
472
 
332
473
  chmod +x "$rvm_ruby_home"/bin/*
@@ -336,10 +477,13 @@ RubyWrapper
336
477
  __rvm_bin_script
337
478
  __rvm_post_install
338
479
  else
480
+
339
481
  __rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_repo_url" "rvm_ruby_url"
482
+
340
483
  if [[ -z "$rvm_ruby_url" ]] ; then
341
484
  "$rvm_scripts_path/log" "fail" "rvm does not know the rvm repo url for '${rvm_ruby_interpreter}_${rvm_ruby_version}'"
342
485
  result=1
486
+
343
487
  else
344
488
  rvm_ruby_repo_url="$rvm_ruby_url"
345
489
  if [[ ${rvm_make_flags_flag:-0} -eq 1 ]] ; then __rvm_make_flags ; fi
@@ -349,65 +493,99 @@ RubyWrapper
349
493
  ;;
350
494
 
351
495
  rbx|rubinius)
496
+
352
497
  "$rvm_scripts_path/log" "info" "#dependency installation"
353
498
 
354
499
  # Ensure we have a 1.8.7 compatible ruby installed.
355
500
  __rvm_ensure_has_18_compat_ruby || return 1
501
+
356
502
  # TODO: use 'rvm gems load' here:
357
503
  unset CFLAGS LDFLAGS ARCHFLAGS # Important.
358
504
 
359
505
  unset BUNDLE_PATH GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC
506
+
360
507
  __rvm_remove_rvm_from_path
508
+
361
509
  __rvm_conditionally_add_bin_path ; export PATH
510
+
362
511
  builtin hash -r
363
512
 
364
513
  if [[ -n "$(echo $rvm_ruby_version | awk '/^1\.0/')" ]] && [[ $rvm_head_flag -eq 0 ]] ; then
514
+
365
515
  "$rvm_scripts_path/log" "info" "#downloading $rvm_ruby_package_file, this may take a while depending on your connection..."
516
+
366
517
  "$rvm_scripts_path/fetch" "$rvm_ruby_url"
367
- result=$? ; if [[ "$result" -gt 0 ]] ; then
368
- "$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the source. Aborting the installation." ; return $result
369
- fi
370
- __rvm_run "extract" "gunzip < \"$rvm_archives_path/$(basename $rvm_ruby_package_file)\" | tar xf - -C $rvm_src_path" "Extracting $rvm_ruby_package_file ..."
518
+ result=$?
371
519
 
372
- result=$? ; if [[ "$result" -gt 0 ]] ; then
373
- "$rvm_scripts_path/log" "error" "There has been an error while trying to extract the source. Aborting the installation." ; return $result
520
+ if [[ "$result" -gt 0 ]] ; then
521
+ "$rvm_scripts_path/log" "error" \
522
+ "There has been an error while trying to fetch the source. Aborting the installation."
523
+ return $result
524
+ fi
525
+ __rvm_run "extract" \
526
+ "gunzip < \"$rvm_archives_path/$(basename $rvm_ruby_package_file)\" | tar xf - -C $rvm_src_path" "Extracting $rvm_ruby_package_file ..."
527
+ result=$?
528
+
529
+ if [[ "$result" -gt 0 ]] ; then
530
+ "$rvm_scripts_path/log" "error" \
531
+ "There has been an error while trying to extract the source. Aborting the installation."
532
+ return $result
374
533
  fi
375
534
 
376
535
  # Remove the left over folder first.
377
536
  rm -rf "$rvm_ruby_src_path"
537
+
378
538
  mv "$rvm_src_path/rubinius-${rvm_ruby_version}" "$rvm_ruby_src_path"
379
539
  else
380
540
  __rvm_db "rubinius_repo_url" "rvm_ruby_repo_url"
381
541
  #rvm_ruby_home="$rvm_rubies_path/$rvm_ruby_interpreter-$rvm_ruby_version"
382
542
  __rvm_fetch_from_github "rbx"
383
- result=$? ; if [[ "$result" -gt 0 ]] ; then
384
- "$rvm_scripts_path/log" "error" "There has been an error while fetching the rbx git repo. Aborting the installation." ; return $result
543
+ result=$?
544
+
545
+ if [[ "$result" -gt 0 ]] ; then
546
+ "$rvm_scripts_path/log" "error" \
547
+ "There has been an error while fetching the rbx git repo. Aborting the installation."
548
+ return $result
385
549
  fi
386
550
  fi
387
551
 
388
- builtin cd "$rvm_ruby_src_path" ; chmod +x ./configure
552
+ builtin cd "$rvm_ruby_src_path"
553
+
554
+ chmod +x ./configure
389
555
 
390
556
  __rvm_apply_patches
391
- result=$? ; if [[ "$result" -gt 0 ]] ; then
392
- "$rvm_scripts_path/log" "error" "There has been an error while trying to apply patches to rubinius. Aborting the installation." ; return $result
557
+ result=$?
558
+
559
+ if [[ "$result" -gt 0 ]] ; then
560
+ "$rvm_scripts_path/log" "error" \
561
+ "There has been an error while trying to apply patches to rubinius. Aborting the installation."
562
+ return $result
393
563
  fi
394
564
 
395
565
  __rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
396
566
 
397
567
  export ruby="$(__rvm_18_compat_ruby)"
398
568
 
399
- rvm_ruby_configure_flags="${rvm_ruby_configure_flags:-"--skip-system"}"
400
- rvm_ruby_configure="$rvm_bin_path/$ruby configure --prefix=$rvm_ruby_home $db_configure_flags $rvm_ruby_configure_flags" ; message="Configuring rbx"
569
+ rvm_configure_flags="${rvm_configure_flags:-"--skip-system"}"
570
+
571
+ rvm_ruby_configure="$rvm_bin_path/$ruby configure --prefix=$rvm_ruby_home $db_configure_flags $rvm_configure_flags" ; message="Configuring rbx"
572
+
401
573
  if [[ "$rvm_llvm_flag" = "0" ]] ; then
402
574
  rvm_ruby_configure="$rvm_ruby_configure --disable-llvm"
575
+
403
576
  else
404
577
  if [[ "$rvm_ruby_patch_level" = "rc1" ]] ; then
405
578
  rvm_ruby_configure="$rvm_ruby_configure --enable-llvm"
406
579
  fi
407
580
  fi
581
+
408
582
  __rvm_run "configure" "$rvm_ruby_configure" "$message"
409
- result=$? ; if [[ "$result" -gt 0 ]] ; then
410
- "$rvm_scripts_path/log" "error" "There has been an error while running '$rvm_ruby_configure'. Aborting the installation." ; return $result
583
+ result=$?
584
+
585
+ if [[ "$result" -gt 0 ]] ; then
586
+ "$rvm_scripts_path/log" "error" \
587
+ "There has been an error while running '$rvm_ruby_configure'. Aborting the installation."
588
+ return $result
411
589
  fi
412
590
 
413
591
  if [[ "$rvm_trace_flag" -eq 1 ]] ; then
@@ -415,9 +593,14 @@ RubyWrapper
415
593
  else
416
594
  rvm_ruby_make="$rvm_wrappers_path/$ruby/rake install" ; message="Compiling rbx"
417
595
  fi
596
+
418
597
  __rvm_run "rake" "$rvm_ruby_make" "$message"
419
- result=$? ; if [[ "$result" -gt 0 ]] ; then
420
- "$rvm_scripts_path/log" "error" "There has been an error while running '$rvm_ruby_configure'. Aborting the installation." ; return $result
598
+ result=$?
599
+
600
+ if [[ "$result" -gt 0 ]] ; then
601
+ "$rvm_scripts_path/log" "error" \
602
+ "There has been an error while running '$rvm_ruby_configure'. Aborting the installation."
603
+ return $result
421
604
  fi ; unset ruby
422
605
 
423
606
  # Symlink rubinius wrappers
@@ -425,25 +608,39 @@ RubyWrapper
425
608
 
426
609
  # Install IRB Wrapper on Rubinius.
427
610
  file_name="$rvm_ruby_home/bin/irb"
611
+
428
612
  rm -f "$file_name"
613
+
429
614
  printf '#!/usr/bin/env bash\n' > "$file_name"
615
+
430
616
  printf "exec '$rvm_ruby_home/bin/rbx' 'irb' \"\$@\"\n" >> "$file_name"
617
+
431
618
  [[ -f "$file_name" ]] && chmod +x "$file_name"
432
619
 
433
620
  # Install Gem Wrapper on Rubinius.
434
621
  file_name="$rvm_ruby_home/bin/gem"
622
+
435
623
  cp -f "$rvm_ruby_home/lib/bin/gem.rb" "$file_name"
624
+
436
625
  __rvm_inject_ruby_shebang "$file_name"
437
- [[ -f "$file_name" ]] && chmod +x "$file_name"
626
+
627
+ if [[ -f "$file_name" ]] ; then
628
+ chmod +x "$file_name"
629
+ fi
630
+
438
631
  unset file_name
439
632
 
440
- binaries="erb ri rdoc"
633
+ binaries=(erb ri rdoc)
634
+
441
635
  __rvm_post_install
636
+
442
637
  __rvm_irbrc
638
+
443
639
  __rvm_bin_script
444
640
  ;;
445
641
 
446
642
  jruby)
643
+
447
644
  if ! command -v java > /dev/null; then
448
645
  printf "java must be installed and in your path in order to install JRuby." ; return 1
449
646
  fi
@@ -451,23 +648,39 @@ RubyWrapper
451
648
  builtin cd "$rvm_src_path"
452
649
 
453
650
  __rvm_fetch_ruby
454
- result=$? ; if [[ "$result" -gt 0 ]] ; then
455
- "$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the source. Aborting the installation." ; return $result
651
+ result=$?
652
+
653
+ if [[ "$result" -gt 0 ]] ; then
654
+ "$rvm_scripts_path/log" "error" \
655
+ "There has been an error while trying to fetch the source. Aborting the installation."
656
+ return $result
456
657
  fi
457
658
 
458
659
  builtin cd "$rvm_ruby_src_path"
459
- if [[ $rvm_head_flag -eq 1 ]] ; then __rvm_run "ant.dist" "ant dist" "#ant dist" ; fi
460
660
 
461
- mkdir -p "$rvm_ruby_home/bin/"
462
- if "$rvm_scripts_path/match" "$rvm_ruby_version" "1\.3" || "$rvm_scripts_path/match" "$rvm_ruby_version" "1\.2" ; then
463
- __rvm_run "nailgun" "builtin cd \"$rvm_ruby_src_path/tool/nailgun\" && make $rvm_make_flags" "Building Nailgun"
464
- else
465
- __rvm_run "nailgun" "builtin cd \"$rvm_ruby_src_path/tool/nailgun\" && ./configure --prefix=$rvm_ruby_home && make $rvm_make_flags" "Building Nailgun"
661
+ if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
662
+ __rvm_run "ant.dist" "ant dist" "#ant dist"
466
663
  fi
467
664
 
468
- if [[ -z "${rvm_ruby_home:-""}" || "$rvm_ruby_home" = "/" ]] ; then echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000 ; fi
665
+ mkdir -p "$rvm_ruby_home/bin/"
666
+
667
+ case "$rvm_ruby_version" in
668
+ 1.3|1.2)
669
+ __rvm_run "nailgun" \
670
+ "builtin cd \"$rvm_ruby_src_path/tool/nailgun\" && make $rvm_make_flags" "Building Nailgun"
671
+ ;;
672
+ *)
673
+ __rvm_run "nailgun" \
674
+ "builtin cd \"$rvm_ruby_src_path/tool/nailgun\" && ./configure --prefix=$rvm_ruby_home && make $rvm_make_flags" "Building Nailgun"
675
+ ;;
676
+ esac
677
+
678
+ if [[ -z "${rvm_ruby_home:-""}" || "$rvm_ruby_home" = "/" ]] ; then
679
+ echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000
680
+ fi
469
681
 
470
682
  rm -rf "$rvm_ruby_home"
683
+
471
684
  __rvm_run "install" "/bin/cp -Rf $rvm_ruby_src_path $rvm_ruby_home" "#installing JRuby to $rvm_ruby_home"
472
685
 
473
686
  (
@@ -482,22 +695,28 @@ RubyWrapper
482
695
  # mv $rvm_ruby_home/bin/jruby.new $rvm_ruby_home/bin/jruby
483
696
  chmod +x "$rvm_ruby_home/bin/jruby"
484
697
 
485
- for binary in jrubyc jirb_swing jirb jgem rdoc ri spec autospec testrb ast generate_yaml_index.rb ; do
698
+ binaries=(jrubyc jirb_swing jirb jgem rdoc ri spec autospec testrb ast generate_yaml_index.rb)
699
+ for binary in "${binaries[@]}" ; do
486
700
  __rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
487
- done ; unset binary
701
+ done
488
702
 
489
703
  __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/rake"
490
704
 
491
705
  __rvm_rubygems_setup
706
+
492
707
  __rvm_irbrc
708
+
493
709
  __rvm_bin_script
710
+
494
711
  __rvm_use
495
712
 
496
713
  __rvm_post_install
497
714
 
498
715
  # jruby ships with some built in gems, copy them in to place.
499
716
  if [[ -d "$rvm_ruby_home/lib/ruby/gems/1.8" ]]; then
717
+
500
718
  "$rvm_scripts_path/log" "info" "Copying across included gems"
719
+
501
720
  cp -R "$rvm_ruby_home/lib/ruby/gems/1.8/" "$GEM_HOME/"
502
721
  fi
503
722
  ;;
@@ -506,35 +725,54 @@ RubyWrapper
506
725
  __rvm_ensure_has_18_compat_ruby
507
726
 
508
727
  "$rvm_scripts_path/log" "info" "Running MagLev prereqs checking script."
728
+
509
729
  "$rvm_scripts_path/maglev"
510
- result=$? ; if [[ "$result" -gt 0 ]] ; then
511
- "$rvm_scripts_path/log" "error" "Prerequisite checks have failed. Aborting the installation." ; return $result
730
+ result=$?
731
+
732
+ if [[ "$result" -gt 0 ]] ; then
733
+ "$rvm_scripts_path/log" "error" \
734
+ "Prerequisite checks have failed. Aborting the installation."
735
+ return $result
512
736
  fi
513
737
 
514
738
  builtin cd "$rvm_src_path"
515
739
 
516
740
  if [[ ! -d "$rvm_src_path/$rvm_ruby_string" || ${rvm_force_flag:-0} -eq 1 ]] ; then
741
+
517
742
  rm -rf "$rvm_src_path/$rvm_ruby_string/" "$rvm_src_path/$rvm_ruby_string/"
743
+
518
744
  __rvm_fetch_ruby
519
- result=$? ; if [[ "$result" -gt 0 ]] ; then
520
- "$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the source. Aborting the installation." ; return $result
745
+ result=$?
746
+
747
+ if [[ "$result" -gt 0 ]] ; then
748
+ "$rvm_scripts_path/log" "error" \
749
+ "There has been an error while trying to fetch the source. Aborting the installation."
750
+ return $result
521
751
  fi
522
752
  fi
523
753
 
524
- if [[ $rvm_head_flag -eq 1 ]] ; then
754
+ if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
755
+
525
756
  builtin cd "$rvm_ruby_src_path"
757
+
526
758
  rvm_gemstone_package_file="GemStone-$(\grep ^GEMSTONE version.txt | cut -f2 -d-).$(uname -sm | \tr ' ' '-')"
759
+
527
760
  rvm_gemstone_url="${rvm_gemstone_url:-"$maglev_url/${rvm_gemstone_package_file}.${rvm_archive_extension}"}"
528
761
  fi
529
762
 
530
763
  "$rvm_scripts_path/log" "info" "Downloading the GemStone package, this may take a while depending on your connection..."
531
764
 
532
765
  "$rvm_scripts_path/fetch" "$rvm_gemstone_url"
533
- result=$? ; if [[ "$result" -gt 0 ]] ; then
534
- "$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the GemStone package. Aborting the installation." ; return $result
766
+ result=$?
767
+
768
+ if [[ "$result" -gt 0 ]] ; then
769
+ "$rvm_scripts_path/log" "error" \
770
+ "There has been an error while trying to fetch the GemStone package. Aborting the installation."
771
+ return $result
535
772
  fi
536
773
 
537
774
  builtin cd "$rvm_src_path"
775
+
538
776
  if [[ -s "$rvm_ruby_package_file" ]] ; then
539
777
  mv "$rvm_ruby_package_file" "$rvm_ruby_src_path"
540
778
  fi
@@ -542,15 +780,24 @@ RubyWrapper
542
780
  builtin cd "$rvm_ruby_src_path"
543
781
 
544
782
  __rvm_run "gemstone.extract" "gunzip < \"$rvm_archives_path/${rvm_gemstone_package_file}.${rvm_archive_extension}\" | tar xf - -C $rvm_ruby_src_path"
545
- result=$? ; if [[ "$result" -gt 0 ]] ; then
546
- "$rvm_scripts_path/log" "error" "There has been an error while trying to extract the GemStone package. Aborting the installation." ; return $result
783
+ result=$?
784
+
785
+ if [[ "$result" -gt 0 ]] ; then
786
+ "$rvm_scripts_path/log" "error" \
787
+ "There has been an error while trying to extract the GemStone package. Aborting the installation."
788
+ return $result
547
789
  fi
548
790
 
549
- chmod -R 777 "$rvm_gemstone_package_file" # for now.
791
+ chmod -R 777 "$rvm_gemstone_package_file" # for now. # WTF?! Crack.smoke!(:huff)
792
+
550
793
  ln -nfs "$rvm_gemstone_package_file" "gemstone"
551
794
 
552
- if [[ -z "$rvm_ruby_home" ]] || [[ "$rvm_ruby_home" = "/" ]] ; then echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000 ; fi
553
- rm -rf $rvm_ruby_home
795
+ if [[ -z "${rvm_ruby_home:-""}" || "$rvm_ruby_home" = "/" ]] ; then
796
+ echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000
797
+ else
798
+ rm -rf $rvm_ruby_home
799
+ fi
800
+
554
801
  __rvm_run "install" "/bin/cp -Rf $rvm_ruby_src_path $rvm_ruby_home" "Installing maglev to $rvm_ruby_home"
555
802
 
556
803
  (
@@ -560,9 +807,10 @@ RubyWrapper
560
807
  done ; unset binary
561
808
  )
562
809
 
563
- for binary in maglev-ruby maglev-irb maglev-gem ; do
810
+ binaries=(maglev-ruby maglev-irb maglev-gem)
811
+ for binary in "${binaries[@]}" ; do
564
812
  __rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
565
- done ; unset binary
813
+ done
566
814
 
567
815
  builtin cd "$rvm_ruby_home"
568
816
  if [[ $rvm_head_flag -eq 1 ]] ; then
@@ -591,7 +839,9 @@ RubyWrapper
591
839
  # TODO: Figure out if anything needs to be done with rubygems.
592
840
  #__rvm_rubygems_setup
593
841
  __rvm_irbrc
842
+
594
843
  __rvm_bin_script
844
+
595
845
  __rvm_use
596
846
  ;;
597
847
 
@@ -601,11 +851,16 @@ RubyWrapper
601
851
  fi
602
852
 
603
853
  if [[ $rvm_head_flag -eq 1 ]] ; then
854
+
604
855
  mono_version="$(mono -V | head -n 1 | cut -d ' ' -f5)"
856
+
605
857
  if "$rvm_scripts_path/match" "$mono_version" "([0-9]+)\.([0-9]+)\.?([0-9]+)?" ; then
858
+
606
859
  mono_major_ver="$(echo "$mono_version" | cut -d '.' -f1)"
860
+
607
861
  mono_minor_ver="$(echo "$mono_version" | cut -d '.' -f2)"
608
- if [[ $mono_major_ver -lt 2 ]] || ( [[ $mono_major_ver -eq 2 ]] && [[ $mono_minor_ver -lt 6 ]] ) ; then
862
+
863
+ if [[ $mono_major_ver -lt 2 ]] || ( [[ $mono_major_ver -eq 2 && $mono_minor_ver -lt 6 ]] ) ; then
609
864
  printf "Mono 2.6 (or greater) must be installed and in your path in order to build IronRuby from the repository."
610
865
  printf "Version detected: ${mono_version}"
611
866
  return 1
@@ -618,7 +873,9 @@ RubyWrapper
618
873
  __rvm_ensure_has_18_compat_ruby
619
874
 
620
875
  __rvm_fetch_ruby
876
+
621
877
  if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
878
+
622
879
  builtin cd "$rvm_ruby_src_path"
623
880
 
624
881
  compatible_ruby="$(__rvm_18_compat_ruby)"
@@ -658,7 +915,7 @@ RubyWrapper
658
915
  fi
659
916
 
660
917
  binaries=(gem irb rdoc rake ri ruby)
661
- for binary_name in ${binaries[@]} ; do
918
+ for binary_name in "${binaries[@]}" ; do
662
919
  if [[ -s "$rvm_ruby_home/bin/$binary_name" ]] ; then
663
920
  tr -d '\r' < "$rvm_ruby_home/bin/$binary_name" > "$rvm_ruby_home/bin/$binary_name.new"
664
921
  #sed -e '1,1s=.*=#!'"/usr/bin/env ir=" "$rvm_ruby_home/bin/$binary_name" > "$rvm_ruby_home/bin/$binary_name.new"
@@ -676,10 +933,15 @@ RubyWrapper
676
933
  ;;
677
934
 
678
935
  mput|shyouhei)
936
+
679
937
  if [[ ${rvm_make_flags_flag:-0} -eq 1 ]] ; then __rvm_make_flags ; fi
938
+
680
939
  unset BUNDLE_PATH GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC
940
+
681
941
  __rvm_remove_rvm_from_path
942
+
682
943
  __rvm_conditionally_add_bin_path ; export PATH
944
+
683
945
  builtin hash -r
684
946
 
685
947
  rvm_ruby_home="$rvm_rubies_path/$rvm_ruby_interpreter-$rvm_ruby_version"
@@ -687,48 +949,81 @@ RubyWrapper
687
949
  __rvm_fetch_from_github "mput" "trunk"
688
950
 
689
951
  __rvm_apply_patches
690
- result=$? ; if [[ "$result" -gt 0 ]] ; then
691
- "$rvm_scripts_path/log" "error" "There has been an error while trying to apply patches to mput. Aborting the installation." ; return $result
952
+ result=$?
953
+
954
+ if [[ "$result" -gt 0 ]] ; then
955
+ "$rvm_scripts_path/log" "error" \
956
+ "There has been an error while trying to apply patches to mput. Aborting the installation."
957
+ return $result
692
958
  fi
693
959
 
694
960
  if [[ ! -s "$rvm_ruby_src_path/configure" ]] ; then
961
+
695
962
  if command -v autoconf &> /dev/null ; then
963
+
696
964
  __rvm_run "autoconf" "autoconf" "Running autoconf"
965
+
697
966
  else
698
- result=$?; "$rvm_scripts_path/log" "fail" "rvm expects autoconf to install this ruby interpreter, autoconf was not found in PATH. Aborting installation." ; return $result
967
+ "$rvm_scripts_path/log" "fail" \
968
+ "rvm expects autoconf to install this ruby interpreter, autoconf was not found in PATH. Aborting installation."
969
+ return $result
699
970
  fi
700
971
  fi
701
972
 
702
973
  if [[ -s ./Makefile ]] && [[ -z "$rvm_reconfigure_flag" ]] ; then
703
- if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
704
- "$rvm_scripts_path/log" "debug" "Skipping configure step, Makefile exists so configure must have already been run."
705
- fi
974
+
975
+ if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
976
+ "$rvm_scripts_path/log" "debug" "Skipping configure step, Makefile exists so configure must have already been run."
977
+ fi
978
+
706
979
  elif [[ -n "$rvm_ruby_configure" ]] ; then
980
+
707
981
  __rvm_run "configure" "$rvm_ruby_configure"
708
- result=$? ; if [[ "$result" -gt 0 ]] ; then
709
- "$rvm_scripts_path/log" "error" "There has been an error while trying to configure the source. Aborting the installation." ; return $result
710
- fi
982
+ result=$?
983
+
984
+ if [[ "$result" -gt 0 ]] ; then
985
+ "$rvm_scripts_path/log" "error" \
986
+ "There has been an error while trying to configure the source. Aborting the installation."
987
+ return $result
988
+ fi
711
989
 
712
990
  elif [[ -s ./configure ]] ; then
713
- local configure_command="./configure --prefix=$rvm_ruby_home $rvm_ruby_configure_flags"
714
- __rvm_run "configure" "" "Configuring $rvm_ruby_string using $rvm_ruby_configure_flags, this may take a while depending on your cpu(s)..."
715
- result=$? ; if [[ "$result" -gt 0 ]] ; then
716
- "$rvm_scripts_path/log" "error" "There has been an error while trying to configure the source. Aborting the installation." ; return $result
717
- fi
718
- else
719
- "$rvm_scripts_path/log" "error" "Skipping configure step, 'configure' script does not exist, did autoconf not run successfully?"
991
+ local configure_command="./configure --prefix=$rvm_ruby_home $rvm_configure_flags"
992
+
993
+ __rvm_run "configure" "" "Configuring $rvm_ruby_string using $rvm_configure_flags, this may take a while depending on your cpu(s)..."
994
+ result=$?
995
+
996
+ if [[ "$result" -gt 0 ]] ; then
997
+ "$rvm_scripts_path/log" "error" \
998
+ "There has been an error while trying to configure the source. Aborting the installation."
999
+ return $result
720
1000
  fi
721
1001
 
1002
+ else
1003
+ "$rvm_scripts_path/log" "error" \
1004
+ "Skipping configure step, 'configure' script does not exist, did autoconf not run successfully?"
1005
+ fi
1006
+
722
1007
  rvm_ruby_make=${rvm_ruby_make:-"make"}
1008
+
723
1009
  __rvm_run "make" "$rvm_ruby_make $rvm_make_flags" "Compiling $rvm_ruby_string, this may take a while depending on your cpu(s)..."
724
- result=$? ; if [[ "$result" -gt 0 ]] ; then
725
- "$rvm_scripts_path/log" "error" "There has been an error while trying to run make. Aborting the installation." ; return $result
1010
+ result=$?
1011
+
1012
+ if [[ "$result" -gt 0 ]] ; then
1013
+ "$rvm_scripts_path/log" "error" \
1014
+ "There has been an error while trying to run make. Aborting the installation."
1015
+ return $result
726
1016
  fi
727
1017
 
728
1018
  rvm_ruby_make_install=${rvm_ruby_make_install:-"make install"}
1019
+
729
1020
  __rvm_run "install" "$rvm_ruby_make_install" "Installing $rvm_ruby_string"
730
- result=$? ; if [[ "$result" -gt 0 ]] ; then
731
- "$rvm_scripts_path/log" "error" "There has been an error while trying to run make install. Aborting the installation." ; return $result
1021
+ result=$?
1022
+
1023
+ if [[ "$result" -gt 0 ]] ; then
1024
+ "$rvm_scripts_path/log" "error" \
1025
+ "There has been an error while trying to run make install. Aborting the installation."
1026
+ return $result
732
1027
  fi
733
1028
 
734
1029
  "$rvm_scripts_path/log" "info" "Installation of $rvm_ruby_string is complete."
@@ -738,20 +1033,22 @@ RubyWrapper
738
1033
  export BUNDLE_PATH="$rvm_ruby_gem_home"
739
1034
 
740
1035
  __rvm_rubygems_setup
1036
+
741
1037
  __rvm_bin_script
1038
+
742
1039
  __rvm_run "chmod.bin" "chmod +x $rvm_ruby_home/bin/*"
1040
+
743
1041
  __rvm_post_install
744
1042
  ;;
745
1043
 
746
1044
  ruby)
1045
+
747
1046
  __rvm_check_for_bison # && Run like hell...
748
- result=$? ; if [[ "$result" -gt 0 ]] ; then return $result ; fi
749
- if [[ ${rvm_make_flags_flag:-0} -eq 1 ]] ; then __rvm_make_flags ; fi
1047
+ if [[ $? -gt 0 ]] ; then return $result ; fi
750
1048
 
751
- (
752
- __rvm_install_source $*
753
- )
1049
+ if [[ ${rvm_make_flags_flag:-0} -eq 1 ]] ; then __rvm_make_flags ; fi
754
1050
 
1051
+ ( __rvm_install_source $* )
755
1052
  result=$?
756
1053
  ;;
757
1054
 
@@ -765,38 +1062,57 @@ RubyWrapper
765
1062
 
766
1063
  rvm_hook="after_install" ; source "$rvm_scripts_path/hook"
767
1064
 
768
- if [[ -n "$ruby_options" ]] ; then RUBYOPT="$ruby_options" ; export RUBYOPT ; fi
1065
+ if [[ -n "$ruby_options" ]] ; then
1066
+ RUBYOPT="$ruby_options"
1067
+ export RUBYOPT
1068
+ fi
769
1069
 
770
1070
  return $result
771
1071
  }
772
1072
 
773
1073
  __rvm_fetch_from_github() {
774
1074
  rm -rf "$rvm_ruby_src_path"
1075
+
775
1076
  if [[ ! -d "$rvm_ruby_repo_path/.git" ]] ; then
1077
+
776
1078
  rm -rf "$rvm_ruby_repo_path"
1079
+
777
1080
  builtin cd "$rvm_home"
1081
+
778
1082
  __rvm_run "$1.repo" "git clone --depth 1 $rvm_ruby_repo_url $rvm_ruby_repo_path" "Cloning $rvm_ruby_repo_url"
779
- result=$? ; if [[ "$result" -gt 0 ]] ; then
1083
+ result=$?
1084
+
1085
+ if [[ "$result" -gt 0 ]] ; then
780
1086
  rvm_ruby_repo_http_url="${rvm_ruby_repo_url//git:/http:}"
1087
+
781
1088
  "$rvm_scripts_path/log" "info" "Could not fetch $rvm_ruby_repo_url - trying $rvm_ruby_repo_http_url"
1089
+
782
1090
  __rvm_run "$1.repo" "git clone --depth 1 $rvm_ruby_repo_http_url $rvm_ruby_repo_path" "Cloning $rvm_ruby_repo_http_url"
783
1091
  fi
784
1092
  else
785
1093
  local branch="${2:-"master"}"
1094
+
786
1095
  builtin cd "$rvm_ruby_repo_path"
1096
+
787
1097
  __rvm_run "$1.repo" "git pull origin $branch" "Pulling from origin $branch"
788
1098
  fi
1099
+
789
1100
  __rvm_run "$1.copy" "\\cp -R \"$rvm_ruby_repo_path\" \"$rvm_ruby_src_path\"" "Copying from repo to source..."
1101
+
790
1102
  builtin cd "$rvm_ruby_src_path"
791
1103
  }
792
1104
 
793
1105
  __rvm_fetch_ruby() {
794
- [[ -z "$rvm_ruby_selected_flag" ]] && __rvm_select
1106
+ [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] && __rvm_select
1107
+
795
1108
  "$rvm_scripts_path/log" "info" "#fetching ${rvm_ruby_string}"
796
1109
 
797
1110
  if [[ ${rvm_head_flag:-0} -eq 0 && -z "${rvm_ruby_tag:-""}" && -z "${rvm_ruby_revision:-""}" ]] ; then
1111
+
798
1112
  rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_string"}"
1113
+
799
1114
  rvm_ruby_package_file="${rvm_ruby_package_file:-"$rvm_ruby_package_name"}"
1115
+
800
1116
  if [[ "ruby" = "$rvm_ruby_interpreter" ]]; then
801
1117
  rvm_archive_extension="${rvm_archive_extension:-tar.bz2}"
802
1118
  else
@@ -804,45 +1120,77 @@ __rvm_fetch_ruby() {
804
1120
  fi
805
1121
 
806
1122
  if [[ ! -s "$rvm_archives_path/$rvm_ruby_package_file.$rvm_archive_extension" ]] ; then
807
- if [[ "ruby" = "$rvm_ruby_interpreter" ]] ; then
808
- rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_release_version}.${rvm_ruby_major_version}_url")/$rvm_ruby_package_file.$rvm_archive_extension"
809
- elif [[ "ree" = "$rvm_ruby_interpreter" ]] ; then
810
- rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_url")/${rvm_ruby_package_file}.${rvm_archive_extension}"
811
- elif [[ "jruby" = "$rvm_ruby_interpreter" ]] ; then
812
- rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_url")/${rvm_ruby_version}/${rvm_ruby_package_file}.${rvm_archive_extension}"
813
- elif [[ "maglev" = "$rvm_ruby_interpreter" ]] ; then
814
- : # Should already be set from selector
815
- else
816
- rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_url")/${rvm_ruby_package_file}.${rvm_archive_extension}"
817
- fi
818
- "$rvm_scripts_path/log" "info" "Downloading ${rvm_ruby_package_file}, this may take a while depending on your connection..."
1123
+
1124
+ case "$rvm_ruby_interpreter" in
1125
+ ruby)
1126
+ rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_release_version}.${rvm_ruby_major_version}_url")/$rvm_ruby_package_file.$rvm_archive_extension"
1127
+ ;;
1128
+ ree)
1129
+ rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_url")/${rvm_ruby_package_file}.${rvm_archive_extension}"
1130
+ ;;
1131
+ jruby)
1132
+ rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_url")/${rvm_ruby_version}/${rvm_ruby_package_file}.${rvm_archive_extension}"
1133
+ ;;
1134
+ maglev)
1135
+ : # Should already be set from selector
1136
+ ;;
1137
+ *)
1138
+ rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_url")/${rvm_ruby_package_file}.${rvm_archive_extension}"
1139
+ ;;
1140
+ esac
1141
+
1142
+ "$rvm_scripts_path/log" "info" "#downloading ${rvm_ruby_package_file}, this may take a while depending on your connection..."
1143
+
819
1144
  "$rvm_scripts_path/fetch" "${rvm_ruby_url}"
820
- result=$? ; if [[ "$result" -gt 0 ]] ; then
821
- "$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the source. Aborting the installation." ; return $result
1145
+ result=$?
1146
+
1147
+ if [[ "$result" -gt 0 ]] ; then
1148
+ "$rvm_scripts_path/log" "error" \
1149
+ "There has been an error while trying to fetch the source. Aborting the installation."
1150
+ return $result
822
1151
  fi
823
1152
  fi
824
1153
 
825
1154
  if [[ ! -d "$rvm_ruby_src_path" || ${rvm_force_flag:-0} -eq 1 ]] ; then
826
- rm -rf "$rvm_ruby_src_path" # Especially when forced, we want to ensure the destination is missing.
1155
+
1156
+ if [[ -d "$rvm_ruby_src_path" ]] ; then
1157
+ rm -rf "$rvm_ruby_src_path" # Especially when forced, we want to ensure the destination is missing.
1158
+ fi
827
1159
 
828
1160
  mkdir -p "/tmp/rvm_src_$$"
829
1161
 
830
- if [[ "tar.gz" = "$rvm_archive_extension" ]] || [[ "tgz" = "$rvm_archive_extension" ]] ; then
831
- __rvm_run "extract" "gunzip < \"$rvm_archives_path/$rvm_ruby_package_file.$rvm_archive_extension\" | tar xf - -C /tmp/rvm_src_$$" "#extracting $rvm_ruby_package_file to $rvm_ruby_src_path"
832
- result=$? ; if [[ "$result" -gt 0 ]] ; then
833
- "$rvm_scripts_path/log" "error" "There has been an error while trying to extract the source. Aborting the installation." ; return $result
834
- fi
835
- elif [[ "zip" = "$rvm_archive_extension" ]] ; then
836
- __rvm_run "extract" "unzip -q -o $rvm_archives_path/$rvm_ruby_package_file -d /tmp/rvm_src_$$"
837
- result=$? ; if [[ "$result" -gt 0 ]] ; then
838
- "$rvm_scripts_path/log" "error" "There has been an error while trying to extract $rvm_ruby_package_file. Aborting the installation." ; return $result
839
- fi
840
- elif [[ "tar.bz2" = "$rvm_archive_extension" ]] ; then
841
- __rvm_run "extract" "bunzip2 < \"$rvm_archives_path/$rvm_ruby_package_file.$rvm_archive_extension\" | tar xf - -C /tmp/rvm_src_$$" "#extracting $rvm_ruby_package_file to $rvm_ruby_src_path"
842
- result=$? ; if [[ "$result" -gt 0 ]] ; then
843
- "$rvm_scripts_path/log" "error" "There has been an error while trying to extract the source. Aborting the installation." ; return $result
844
- fi
845
- fi
1162
+ case "$rvm_archive_extension" in
1163
+ tar.gz|tgz)
1164
+ __rvm_run "extract" "gunzip < \"$rvm_archives_path/$rvm_ruby_package_file.$rvm_archive_extension\" | tar xf - -C /tmp/rvm_src_$$" "#extracting $rvm_ruby_package_file to $rvm_ruby_src_path"
1165
+ result=$?
1166
+
1167
+ if [[ "$result" -gt 0 ]] ; then
1168
+ "$rvm_scripts_path/log" "error" "There has been an error while trying to extract the source. Aborting the installation." ; return $result
1169
+ fi
1170
+ ;;
1171
+ zip)
1172
+ __rvm_run "extract" "unzip -q -o $rvm_archives_path/$rvm_ruby_package_file -d /tmp/rvm_src_$$"
1173
+ result=$?
1174
+
1175
+ if [[ "$result" -gt 0 ]] ; then
1176
+ "$rvm_scripts_path/log" "error" "There has been an error while trying to extract $rvm_ruby_package_file. Aborting the installation."
1177
+ return $result
1178
+ fi
1179
+ ;;
1180
+ tar.bz2)
1181
+ __rvm_run "extract" "bunzip2 < \"$rvm_archives_path/$rvm_ruby_package_file.$rvm_archive_extension\" | tar xf - -C /tmp/rvm_src_$$" "#extracting $rvm_ruby_package_file to $rvm_ruby_src_path"
1182
+ result=$?
1183
+
1184
+ if [[ "$result" -gt 0 ]] ; then
1185
+ "$rvm_scripts_path/log" "error" "There has been an error while trying to extract the source. Aborting the installation."
1186
+ return $result
1187
+ fi
1188
+ ;;
1189
+ *)
1190
+ "$rvm_scripts_path/log" "error" "Unknown archive format extension '$rvm_archive_extension'. Aborting the installation."
1191
+ return 1
1192
+ ;;
1193
+ esac
846
1194
 
847
1195
  mv "/tmp/rvm_src_$$/$(builtin cd /tmp/rvm_src_$$ ; ls)" "$rvm_ruby_src_path" ; rm -rf "/tmp/rvm_src_$$"
848
1196
 
@@ -857,104 +1205,160 @@ __rvm_fetch_ruby() {
857
1205
  else
858
1206
 
859
1207
  mkdir -p "$rvm_repo_path"
1208
+
860
1209
  if [[ -n "$(echo "$rvm_ruby_url" | awk '/^git/')" ]] ; then
1210
+
861
1211
  if [[ -d "$rvm_ruby_repo_path/.git" ]] ; then
1212
+
862
1213
  builtin cd "$rvm_ruby_repo_path"
1214
+
863
1215
  if [[ -z "$rvm_ruby_revision" ]] ; then
1216
+
864
1217
  "$rvm_scripts_path/log" "info" "Pulling from $rvm_ruby_repo_url, this may take a while depending on your connection..."
1218
+
865
1219
  git pull origin master --force
866
- result=$? ; if [[ "$result" -gt 0 ]] ; then
867
- "$rvm_scripts_path/log" "error" "There has been an error while trying to update the source from the remote repository. Aborting the installation." ; return $result
1220
+
1221
+ result=$?
1222
+
1223
+ if [[ "$result" -gt 0 ]] ; then
1224
+ "$rvm_scripts_path/log" "error" \
1225
+ "There has been an error while trying to update the source from the remote repository. Aborting the installation."
1226
+ return $result
868
1227
  fi
1228
+
869
1229
  else
870
- if [[ -z "$rvm_ruby_sha" ]] ; then
1230
+ if [[ -z "${rvm_ruby_sha:-""}" ]] ; then
871
1231
  git checkout HEAD
872
1232
  else
873
1233
  git checkout $(echo "$rvm_ruby_sha" | sed 's#^s##')
874
1234
  fi
875
- result=$? ; if [[ "$result" -gt 0 ]] ; then
876
- "$rvm_scripts_path/log" "error" "There has been an error while trying to checkout the source branch. Aborting the installation." ; return $result
1235
+ result=$?
1236
+
1237
+ if [[ "$result" -gt 0 ]] ; then
1238
+ "$rvm_scripts_path/log" "error" \
1239
+ "There has been an error while trying to checkout the source branch. Aborting the installation."
1240
+ return $result
877
1241
  fi
878
1242
  fi
1243
+
879
1244
  else
880
1245
  rm -rf "$rvm_ruby_repo_path"
1246
+
881
1247
  rvm_ruby_repo_http_url="${rvm_ruby_repo_url//git:/http:/}"
1248
+
882
1249
  "$rvm_scripts_path/log" "info" "Cloning from $rvm_ruby_repo_url, this may take a while depending on your connection..."
1250
+
883
1251
  git clone --depth 1 "$rvm_ruby_repo_url" "$rvm_ruby_repo_path"
884
- result=$? ; if [[ "$result" -gt 0 ]] ; then
885
- "$rvm_scripts_path/log" "info" "cloning from $rvm_ruby_repo_url failed, now attempting to clone from $rvm_ruby_repo_http_url, this may take a while depending on your connection..."
1252
+ result=$?
1253
+
1254
+ if [[ "$result" -gt 0 ]] ; then
1255
+ "$rvm_scripts_path/log" "info" \
1256
+ "cloning from $rvm_ruby_repo_url failed, now attempting to clone from $rvm_ruby_repo_http_url, this may take a while depending on your connection..."
1257
+
886
1258
  git clone "$rvm_ruby_repo_http_url" "$rvm_ruby_repo_path"
887
- result=$? ; if [[ "$result" -gt 0 ]] ; then
888
- "$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the repository. Aborting the installation." ; return $result
1259
+ result=$?
1260
+
1261
+ if [[ "$result" -gt 0 ]] ; then
1262
+ "$rvm_scripts_path/log" "error" \
1263
+ "There has been an error while trying to fetch the repository. Aborting the installation."
1264
+ return $result
889
1265
  fi
890
1266
  fi
891
1267
  fi
1268
+
892
1269
  else
893
- if [[ -n "$rvm_ruby_tag" ]] ; then
1270
+ if [[ -n "${rvm_ruby_tag:-""}" ]] ; then
894
1271
  # TODO: Check if tag v is valid
895
1272
  rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/tags/$(echo "$rvm_ruby_tag" | sed 's/^t//')"}"
896
- elif [[ -z "$rvm_ruby_version" && $rvm_head_flag -eq 1 ]] ; then
1273
+
1274
+ elif [[ -z "${rvm_ruby_version:-""}" && ${rvm_head_flag:-0} -eq 1 ]] ; then
897
1275
  rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/trunk"}"
898
- elif [[ "$rvm_ruby_major_version" = "9" ]] ; then
899
- if [[ -z "$rvm_ruby_minor_version" || "$rvm_ruby_minor_version" = 3 ]] ; then
1276
+
1277
+ elif [[ "${rvm_ruby_major_version:-""}" = "9" ]] ; then
1278
+
1279
+ if [[ -z "${rvm_ruby_minor_version:-""}" || "${rvm_ruby_minor_version:-""}" = 3 ]] ; then
900
1280
  rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/trunk"}"
1281
+
901
1282
  else
902
1283
  rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/branches/ruby_${rvm_ruby_release_version}_${rvm_ruby_major_version}_${rvm_ruby_minor_version}"}"
903
1284
  fi
904
- elif [[ -z "$rvm_ruby_minor_version" ]] || [[ "$rvm_ruby_major_version.$rvm_ruby_minor_version" = "8.8" ]] ; then
1285
+
1286
+ elif [[ -z "${rvm_ruby_minor_version:-""}" || "${rvm_ruby_major_version:-""}.${rvm_ruby_minor_version:-""}" = "8.8" ]] ; then
905
1287
  rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/branches/ruby_${rvm_ruby_release_version}_${rvm_ruby_major_version}"}"
1288
+
906
1289
  else
907
1290
  rvm_ruby_url="${rvm_ruby_url:-"$rvm_ruby_repo_url/branches/ruby_${rvm_ruby_release_version}_${rvm_ruby_major_version}_${rvm_ruby_minor_version}"}"
908
1291
  fi
1292
+
909
1293
  rvm_rev=""
910
- if [ -n "$rvm_ruby_revision" ] ; then
1294
+
1295
+ if [[ -n "${rvm_ruby_revision:-""}" ]] ; then
911
1296
  rvm_rev="-$rvm_ruby_revision"
912
1297
  fi
913
1298
 
914
1299
  if [[ -d "$rvm_ruby_repo_path/.svn" ]] ; then
1300
+
915
1301
  builtin cd "$rvm_ruby_repo_path"
1302
+
916
1303
  "$rvm_scripts_path/log" "info" "Updating ruby from $rvm_ruby_url"
1304
+
917
1305
  __rvm_run "svn.switch" "svn switch $rvm_ruby_url"
1306
+
918
1307
  __rvm_run "svn.update" "svn update"
919
- if [[ -n "$rvm_rev" ]] ; then
1308
+
1309
+ if [[ -n "${rvm_rev:-""}" ]] ; then
920
1310
  "$rvm_scripts_path/log" "info" "Checking out revision ${rvm_rev/-r/-r } from $rvm_ruby_url"
1311
+
921
1312
  __rvm_run "svn.checkout" "svn update -q ${rvm_rev/-r/-r }"
922
1313
  fi
923
1314
  else
924
1315
  rm -rf "$rvm_ruby_repo_path"
1316
+
925
1317
  __rvm_run "svn.checkout" "svn checkout -q ${rvm_rev/-r/-r } $rvm_ruby_url $rvm_ruby_repo_path" "Downloading source from ${rvm_ruby_url}."
926
1318
  fi
927
- result=$? ; if [[ "$result" -gt 0 ]] ; then
928
- "$rvm_scripts_path/log" "error" "There has been an error while trying to fetch / update the source. Aborting the installation." ; return $result
929
- fi
1319
+ result=$?
930
1320
 
1321
+ if [[ "$result" -gt 0 ]] ; then
1322
+ "$rvm_scripts_path/log" "error" \
1323
+ "There has been an error while trying to fetch / update the source. Aborting the installation."
1324
+ return $result
1325
+ fi
931
1326
  fi
1327
+
932
1328
  "$rvm_scripts_path/log" "info" "Copying from repo to src path..."
1329
+
933
1330
  rm -rf "$rvm_ruby_src_path"
1331
+
934
1332
  cp -R "$rvm_ruby_repo_path" "$rvm_ruby_src_path"
935
1333
  fi
936
1334
  }
937
1335
 
938
1336
  __rvm_check_default() {
939
- default_ruby_interpreter="$(rvm alias show default 2>/dev/null | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"
940
- current_ruby_interpreter="$(echo "$rvm_ruby_string" | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"
941
- if [[ -n "$current_ruby_interpreter" && "$current_ruby_interpreter" == "$default_ruby_interpreter" ]]; then
1337
+
1338
+ local default_ruby_interpreter="$(rvm alias show default 2>/dev/null | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"
1339
+
1340
+ local current_ruby_interpreter="$(echo "$rvm_ruby_string" | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"
1341
+
1342
+ if [[ -n "$current_ruby_interpreter" && "$current_ruby_interpreter" = "$default_ruby_interpreter" ]]; then
942
1343
  __rvm_run_with_env 'default.restore' 'system' 'rvm use system --default' 'Removing default ruby interpreter'
943
1344
  fi
944
- unset default_ruby_interpreter current_ruby_interpreter
945
1345
  }
946
1346
 
947
1347
  __rvm_uninstall_ruby() {
948
- if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
949
1348
 
950
- if [[ -n "$rvm_ruby_string" ]] ; then
1349
+ if [[ ${rvm_ruby_selected_flag} -eq 0 ]] ; then __rvm_select ; fi
1350
+
1351
+ if [[ -n "${rvm_ruby_string:-""}" ]] ; then
1352
+
951
1353
  for dir in "$rvm_rubies_path" ; do
952
1354
  if [[ -d "$dir/$rvm_ruby_string" ]] ; then
953
1355
  "$rvm_scripts_path/log" "info" "Removing $dir/$rvm_ruby_string..."
1356
+
954
1357
  rm -rf $dir/$rvm_ruby_string
955
1358
  else
956
1359
  "$rvm_scripts_path/log" "info" "$dir/$rvm_ruby_string has already been removed."
957
1360
  fi
1361
+
958
1362
  if [[ -e "$rvm_bin_path/$rvm_ruby_string" ]] ; then
959
1363
  rm -f "$rvm_bin_path/$rvm_ruby_string"
960
1364
  fi
@@ -968,7 +1372,11 @@ __rvm_uninstall_ruby() {
968
1372
 
969
1373
  else
970
1374
  "$rvm_scripts_path/log" "fail" "Cannot uninstall unknown package '$rvm_ruby_string'"
971
- fi ; unset rvm_uninstall_flag
1375
+ fi
1376
+
1377
+ unset rvm_uninstall_flag
1378
+
1379
+ return 0
972
1380
  }
973
1381
 
974
1382
  __rvm_remove_ruby() {
@@ -1010,7 +1418,7 @@ __rvm_remove_gemsets() {
1010
1418
  if [[ ${rvm_gems_flag:-0} -eq 1 ]] ; then
1011
1419
  "$rvm_scripts_path/log" "info" "Removing $rvm_ruby_string gemsets..."
1012
1420
 
1013
- gemsets="$rvm_gems_path/$rvm_ruby_string $(ls -d "${rvm_gems_path}"/* | awk '/'$rvm_ruby_string'@/')"
1421
+ gemsets="$rvm_gems_path/$rvm_ruby_string $(builtin cd "${rvm_gems_path}"/ ; find * -type d -maxdepth 0 | awk '/'$rvm_ruby_string'@/')"
1014
1422
 
1015
1423
  for gemset in $gemsets ; do
1016
1424
  if [[ -d "$gemset" ]] ; then
@@ -1025,7 +1433,7 @@ __rvm_remove_wrappers() {
1025
1433
 
1026
1434
  local wrappers wrapper
1027
1435
 
1028
- wrappers="$rvm_wrappers_path/$rvm_ruby_string $(ls -d "$rvm_wrappers_path"/* 2>/dev/null | awk '/'$rvm_ruby_string'@/')"
1436
+ wrappers="$rvm_wrappers_path/$rvm_ruby_string $(builtin cd "$rvm_wrappers_path"/ ; find * -type f -maxdepth 0 2>/dev/null | awk '/'$rvm_ruby_string'@/')"
1029
1437
 
1030
1438
  for wrapper in $wrappers ; do
1031
1439
  rm -rf "$wrapper"
@@ -1039,7 +1447,7 @@ __rvm_remove_environments() {
1039
1447
 
1040
1448
  local environments environment
1041
1449
 
1042
- environments="$rvm_environments_path/$rvm_ruby_string $(ls -d "$rvm_environments_path"/* | awk '/'$rvm_ruby_string'@/')"
1450
+ environments="$rvm_environments_path/$rvm_ruby_string $(builtin cd "$rvm_environments_path"/ ; find * -type f -maxdepth 0 | awk '/'$rvm_ruby_string'@/')"
1043
1451
 
1044
1452
  for environment in $environments ; do
1045
1453
  rm -rf "$environment"
@@ -1073,7 +1481,8 @@ __rvm_remove_binaries() {
1073
1481
 
1074
1482
  # Iterate over all binaries and check for symlinked wrappers etc.
1075
1483
  local binary_name
1076
- for binary_name in $(ls "$rvm_bin_path"); do
1484
+
1485
+ for binary_name in $(builtin cd "$rvm_bin_path" ; find * -type f -maxdepth 0); do
1077
1486
  full_binary_path="$rvm_bin_path/$binary_name"
1078
1487
 
1079
1488
  if [[ -L "$full_binary_path" ]] && "$rvm_scripts_path/match" "$(readlink "$full_binary_path")" "$rvm_ruby_string"; then
@@ -1085,17 +1494,24 @@ __rvm_remove_binaries() {
1085
1494
 
1086
1495
  __rvm_post_install() {
1087
1496
  if [[ "$rvm_ruby_interpreter" != "jruby" ]] ; then
1088
- binaries="${binaries:-"gem irb erb ri rdoc testrb rake"}"
1497
+ binaries=(${binaries:-"gem irb erb ri rdoc testrb rake"})
1498
+
1089
1499
  "$rvm_scripts_path/log" "info" "#shebangs adjustment for $rvm_ruby_string ($binaries)."
1090
- for binary in $(echo $binaries) ; do
1500
+
1501
+ for binary in "${binaries[@]}" ; do
1502
+
1091
1503
  if [[ -e "$rvm_ruby_home/bin/$binary" ]] || [[ -e "$rvm_ruby_src_path/bin/$binary" ]] ; then
1504
+
1092
1505
  if [[ "$rvm_ruby_src_path" != "$rvm_ruby_home" ]] && [[ -f "$rvm_ruby_src_path/bin/$binary" ]] ; then
1093
1506
  cp -f "$rvm_ruby_src_path/bin/$binary" "$rvm_ruby_home/bin/$binary"
1094
1507
  elif [[ -f "$rvm_ruby_gem_home/bin/$binary" ]] ; then
1095
1508
  cp -f "$rvm_ruby_gem_home/bin/$binary" "$rvm_ruby_home/bin/$binary"
1096
1509
  fi
1510
+
1097
1511
  __rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
1512
+
1098
1513
  __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/$binary"
1514
+
1099
1515
  chmod +x "$rvm_ruby_home/bin/$binary"
1100
1516
  fi
1101
1517
  done ; unset binary binaries
@@ -1138,40 +1554,51 @@ __rvm_rubygems_setup() {
1138
1554
  if [[ "$install" -eq 0 ]] ; then
1139
1555
  # 1.9.X has it's own built-in gem command
1140
1556
  __rvm_inject_ruby_shebang "$rvm_ruby_src_path/bin/gem"
1557
+
1141
1558
  __rvm_inject_gem_env "$rvm_ruby_home/bin/gem"
1142
1559
 
1143
1560
  cp "$rvm_ruby_src_path/bin/gem" "$rvm_ruby_home/bin/gem"
1144
1561
 
1145
1562
  home="$GEM_HOME" ; path="$GEM_PATH" # Save
1563
+
1146
1564
  for dir in $rvm_ruby_global_gems_path $rvm_ruby_gem_home ; do
1147
1565
  export GEM_HOME="$dir" ; export GEM_PATH="$dir" ; export BUNDLE_PATH="$dir"
1148
1566
  __rvm_run "rubygems.update" "$rvm_ruby_home/bin/gem update --system" "#rubygems update for $dir"
1149
1567
  done ; unset home path dir
1568
+
1150
1569
  GEM_HOME="$home" ; GEM_PATH="$path" ; BUNDLE_PATH="$home"
1151
1570
  export GEM_HOME GEM_PATH BUNDLE_PATH
1152
1571
 
1153
1572
  __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/gem"
1573
+
1154
1574
  __rvm_inject_gem_env "$rvm_ruby_home/bin/gem"
1155
1575
 
1156
1576
  directory_name="$rvm_ruby_home/lib/ruby/gems"
1577
+
1157
1578
  version_number="${rvm_ruby_release_version}.${rvm_ruby_major_version}"
1579
+
1158
1580
  if [[ "$version_number" == "." ]]; then
1159
- version_number="$(\ls "$directory_name" | \grep '^[[:digit:]].[[:digit:]]\(.[[:digit:]]\)\?' | head -n1)"
1581
+ version_number="$(builtin cd "$directory_name" ; find * -type f -maxdepth 0 | \grep '^[[:digit:]].[[:digit:]]\(.[[:digit:]]\)\?' | head -n1)"
1582
+
1160
1583
  if [[ -n "$version_number" ]]; then
1161
1584
  ruby_lib_gem_path="${directory_name}/${version_number}"
1162
1585
  else
1163
1586
  ruby_lib_gem_path=""
1164
1587
  fi
1588
+
1165
1589
  else
1166
1590
  ruby_lib_gem_path="${directory_name}/${version_number}"
1167
1591
  fi
1592
+
1168
1593
  unset directory_name version_number
1169
1594
 
1170
1595
  elif [[ -n "$(echo "$rvm_ruby_interpreter" | awk '/^rbx|jruby/')" ]] ; then
1596
+
1171
1597
  # Hands off rubygems for rbx & jruby
1172
1598
  if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
1173
1599
  "$rvm_scripts_path/log" "debug" "Skipping rubygems update for $rvm_ruby_version"
1174
1600
  fi
1601
+
1175
1602
  ruby_lib_gem_path="$rvm_ruby_home/lib/ruby/gems/jruby"
1176
1603
 
1177
1604
  else
@@ -1216,9 +1643,15 @@ __rvm_rubygems_setup() {
1216
1643
 
1217
1644
  if [[ -n "$ruby_lib_gem_path" ]]; then
1218
1645
  # Add ruby's gem path to ruby's lib direcotry.
1219
- mkdir -p $(dirname "$ruby_lib_gem_path")
1220
- if [[ -d "$ruby_lib_gem_path" ]] ; then \rm -rf "$ruby_lib_gem_path" ; fi
1646
+
1647
+ if [[ -d "$ruby_lib_gem_path" ]] ; then
1648
+ \rm -rf "$ruby_lib_gem_path"
1649
+ fi
1650
+
1651
+ mkdir -p ${ruby_lib_gem_path%\/*}
1652
+
1221
1653
  ln -nfs "$rvm_ruby_gem_home" "$ruby_lib_gem_path"
1654
+
1222
1655
  fi; unset ruby_lib_gem_path
1223
1656
 
1224
1657
  if [[ -s "$rvm_ruby_src_path/bin/rdoc" ]] ; then
@@ -1266,45 +1699,67 @@ __rvm_actual_file() {
1266
1699
  }
1267
1700
 
1268
1701
  __rvm_manage_rubies() {
1269
- unset rvm_gemset_name rvm_ruby_selected_flag
1702
+ local manage_result=0
1703
+ local bin_line=""
1270
1704
 
1271
- rvm_ruby_gem_home=$(echo "${rvm_ruby_gem_home:-""}" | awk -F${rvm_gemset_separator} '{print $1}')
1272
- rvm_ruby_string=$(echo "${rvm_ruby_string:-""}" | awk -F${rvm_gemset_separator} '{print $1}')
1705
+ rvm_gemset_name=""
1706
+ rvm_ruby_selected_flag=0
1273
1707
 
1274
- local manage_result=0
1708
+ rvm_ruby_gem_home="${rvm_ruby_gem_home:-""//${rvm_gemset_separator}*}"
1709
+ rvm_ruby_string="${rvm_ruby_string:-""//${rvm_gemset_separator}*}"
1710
+
1711
+ # Given list of ruby strings.
1712
+ if [[ -n "${rubies_string:-""}" ]] ;then
1275
1713
 
1276
- if [[ -n "$rubies_string" ]] ;then
1277
- for rvm_ruby_string in $(echo "$rubies_string" | \tr ',' ' ') ; do
1714
+ for rvm_ruby_string in "${rubies_string//,/ }" ; do
1278
1715
  current_manage_ruby_string="$rvm_ruby_string"
1716
+
1279
1717
  eval "__rvm_${action}_ruby"
1280
1718
  result="$?"
1719
+
1281
1720
  if [[ "$result" -gt 0 && "$manage_result" = 0 ]]; then
1282
1721
  manage_result="$result"
1283
1722
  fi
1284
- [[ "$result" = 0 && "$action" = "install" ]] && __rvm_record_install "$current_manage_ruby_string"
1723
+
1724
+ if [[ "$result" = 0 && "$action" = "install" ]] ; then
1725
+ __rvm_record_install "$current_manage_ruby_string"
1726
+ fi
1727
+
1285
1728
  unset current_manage_ruby_string
1729
+
1286
1730
  __rvm_unset_ruby_variables
1287
1731
  done
1732
+
1288
1733
  else # all
1734
+
1289
1735
  if [[ "$action" != "install" && "$action" != "remove" && "$action" != "uninstall" ]] ; then
1290
- while read -r bin_line
1736
+
1737
+ local ruby_string
1738
+ while read -r ruby_string
1291
1739
  do # Keep this on second line damnit!
1292
- if [[ -x "$bin_line" ]] ; then
1293
- current_manage_ruby_string="$(dirname "$bin_line" | xargs dirname | xargs basename)"
1294
- rvm_ruby_string="$current_manage_ruby_string"
1740
+
1741
+ if [[ -x "$ruby_string" ]] ; then
1742
+ rvm_ruby_string="$ruby_string"
1743
+
1295
1744
  eval "__rvm_${action}_ruby"
1296
1745
  result="$?"
1746
+
1297
1747
  if [[ "$result" -gt 0 && "$manage_result" = 0 ]]; then
1298
1748
  manage_result="$result"
1299
1749
  fi
1750
+
1300
1751
  # record as current_manage_string to prevent it being overridden.
1301
- [[ "$result" = 0 && "$action" = "install" ]] && __rvm_record_install "$current_manage_ruby_string"
1302
- unset current_manage_ruby_string
1752
+ if [[ "$result" = 0 && "$action" = "install" ]] ; then
1753
+ __rvm_record_install "$ruby_string"
1754
+ fi
1755
+
1303
1756
  __rvm_unset_ruby_variables
1304
1757
  fi
1305
- done < <(ls "$rvm_rubies_path"/*/bin/ruby 2> /dev/null)
1758
+ done < <(builtin cd "$rvm_rubies_path" ; find * -type d -maxdepth 0 2> /dev/null)
1759
+
1306
1760
  else
1307
- "$rvm_scripts_path/log" "warn" 'Really? '"$action"' all? See "rvm list known" and limit the selection to something more sane please :)'
1761
+ "$rvm_scripts_path/log" "warn" \
1762
+ 'Really? '"$action"' all? See "rvm list known" and limit the selection to something more sane please :)'
1308
1763
  fi
1309
1764
  fi
1310
1765