rvm 1.0.11 → 1.0.13

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/scripts/upgrade CHANGED
@@ -3,24 +3,24 @@
3
3
  unset GREP_OPTIONS
4
4
  source "$rvm_path/scripts/base"
5
5
 
6
- usage() {
6
+ usage()
7
+ {
7
8
  printf "
8
9
 
9
10
  Usage:
10
11
 
11
- rvm upgrade prefix [ruby-string]
12
+ rvm upgrade [new ruby] [existing ruby]
12
13
 
13
14
  Description:
14
15
 
15
16
  Upgrades the latest installed ruby with a given ruby string
16
- (e.g. ree) to the latest known version.
17
+ (e.g. ree) to the latest known version or the version specified
17
18
 
18
- " >&2
19
-
20
- exit 1
19
+ "
21
20
  }
22
21
 
23
- confirm() {
22
+ confirm()
23
+ {
24
24
 
25
25
  local confirmation_response
26
26
 
@@ -28,19 +28,25 @@ confirm() {
28
28
 
29
29
  read -r confirmation_response
30
30
 
31
- [[ -z "$confirmation_response" ]] || echo $confirmation_response | \grep -qi '^y\|^Y'
31
+ if [[ -n "$confirmation_response" ]] ; then
32
+ echo $confirmation_response | \grep -qi '^y\|^Y'
33
+ fi
32
34
  }
33
35
 
34
- die_with_error() {
36
+ die_with_error()
37
+ {
35
38
  "$rvm_path/scripts/log" "fail" "$1"
36
39
  exit "${2:-1}"
37
40
  }
38
41
 
39
- expand_ruby_name() {
40
- "$rvm_path/scripts/tools" strings "$1" | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}'
42
+ expand_ruby_name()
43
+ {
44
+ "$rvm_path/scripts/tools" strings "$1" \
45
+ | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}'
41
46
  }
42
47
 
43
- expand_existing_ruby() {
48
+ expand_existing_ruby()
49
+ {
44
50
  local prefix ruby_name
45
51
 
46
52
  prefix="$(expand_ruby_name "$1" | awk -F'-' '{print $1"-"$2}')"
@@ -51,20 +57,29 @@ expand_existing_ruby() {
51
57
  echo "$ruby_name" ; return 0
52
58
  fi
53
59
 
54
- done < <("$rvm_path/scripts/list" strings | tr ' ' '\n' | sort -ur | \grep "^$prefix" | \grep -v '-head$' | head -n1)
60
+ done < <("$rvm_path/scripts/list" strings | tr ' ' '\n' \
61
+ | sort -ur | \grep "^$prefix" | \grep -v '-head$' | head -n1)
55
62
 
56
63
  return 1
57
64
  }
58
65
 
59
- upgrade_ruby() {
66
+ upgrade_ruby()
67
+ {
60
68
 
61
- [[ -z "$source_ruby" ]] && die_with_error "Unable to find a source ruby. Please manually provide one."
69
+ if [[ -z "$source_ruby" ]] ; then
70
+ die_with_error "Unable to find a source ruby. Please manually provide one."
71
+ fi
62
72
 
63
73
  expanded_source="$(expand_ruby_name "$source_ruby")"
64
74
 
65
- [[ -z "$expanded_source" ]] && die_with_error "The source ruby was not a valid ruby string."
75
+ if [[ -z "$expanded_source" ]] ; then
76
+ die_with_error "The source ruby was not a valid ruby string."
77
+ fi
66
78
 
67
- confirm "Are you sure you wish to upgrade from $expanded_source to $expanded_destination?" || die_with_error "Cancelling upgrade."
79
+ if ! confirm "Are you sure you wish to upgrade from $expanded_source to \
80
+ $expanded_destination?" ; then
81
+ die_with_error "Cancelling upgrade."
82
+ fi
68
83
 
69
84
  if [[ ! -d "$rvm_path/rubies/$expanded_destination" ]]; then
70
85
 
@@ -75,7 +90,10 @@ upgrade_ruby() {
75
90
 
76
91
  result="$?"
77
92
 
78
- [[ "$result" -gt 0 ]] && die_with_error "Unable to install ruby $expanded_destination. Please install it manually to continue." "$result"
93
+ if [[ "$result" -gt 0 ]] ; then
94
+ die_with_error "Unable to install ruby $expanded_destination. \
95
+ Please install it manually to continue." "$result"
96
+ fi
79
97
 
80
98
  fi
81
99
 
@@ -91,16 +109,36 @@ upgrade_ruby() {
91
109
  }
92
110
 
93
111
  args=($*)
94
- destination_ruby="${args[0]}"
95
- source_ruby="${args[1]:-"$(expand_existing_ruby "$destination_ruby")"}"
96
- args="$(echo ${args[@]:2}) " # Strip trailing / leading / extra spacing.
112
+ destination_ruby="${args[$__array_start]}"
113
+ args[$__array_start]=""
114
+ args=(${args[@]})
115
+
116
+ source_ruby="${args[$__array_start]:-"$(expand_existing_ruby "$destination_ruby")"}"
117
+ args[$__array_start]=""
118
+ args=(${args[@]})
97
119
 
98
- [[ -z "$source_ruby" ]] && usage
120
+ if [[ -z "${source_ruby:-""}" ]] ; then
121
+ usage >&2
122
+ exit 1
123
+ fi
124
+
125
+ if [[ "help" = "$source_ruby" ]] ; then
126
+ usage
127
+ exit 0
128
+ fi
99
129
 
100
130
  expanded_destination="$(expand_ruby_name "$destination_ruby")"
101
131
 
102
- [[ -z "$source_ruby" ]] && die_with_error "The Source ruby was not specified, a valid ruby string, or not found."
132
+ if [[ -z "$source_ruby" ]] ; then
133
+ die_with_error \
134
+ "Source ruby was either not a recognized ruby string or not installed."
135
+ fi
103
136
 
104
- [[ -z "$expanded_destination" ]] && die_with_error "The destination ruby was not a valid ruby string, or not found."
137
+ if [[ -z "$expanded_destination" ]] ; then
138
+ die_with_error \
139
+ "Destination ruby is not a known ruby string."
140
+ fi
105
141
 
106
142
  upgrade_ruby
143
+
144
+ exit $?
data/scripts/utility CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- __rvm_setup() {
3
+ __rvm_setup()
4
+ {
4
5
  # ZSH has 1 based array indexing, bash has 0 based.
5
6
  if [[ -n "${ZSH_VERSION:-""}" ]] ; then
6
7
  __shell_array_start=1
@@ -13,8 +14,8 @@ __rvm_setup() {
13
14
  fi ; export __shell_array_start
14
15
  }
15
16
 
16
- __rvm_teardown() {
17
-
17
+ __rvm_teardown()
18
+ {
18
19
  if [[ -n "${ZSH_VERSION:-""}" ]] ; then
19
20
 
20
21
  if [[ ${rvm_zsh_clobber:-0} -eq 0 ]] ; then
@@ -55,8 +56,8 @@ __rvm_teardown() {
55
56
  }
56
57
 
57
58
  # Dump the current environment to a file.
58
- __rvm_dump_environment() {
59
-
59
+ __rvm_dump_environment()
60
+ {
60
61
  # Note: This assumes that there is a ','
61
62
  local dump_environment_file dump_environment_type rvm_dump_environment_flag
62
63
 
@@ -66,12 +67,14 @@ __rvm_dump_environment() {
66
67
 
67
68
  if [[ -n "$dump_environment_file" && -n "$dump_environment_type" ]]; then
68
69
 
69
- if [[ "$dump_environment_type" == "atheis"* ]] && [[ -f "$dump_environment_file" ]] ; then
70
+ if [[ "$dump_environment_type" == "atheis"* && -f "$dump_environment_file" ]] ; then
70
71
  # TODO: Query Darcy about the ln.
71
- \rm -f "$dump_environment_file" && ln -s /dev/null "$dump_environment_file" >/dev/null 2>&1
72
+ \rm -f "$dump_environment_file" \
73
+ && ln -s /dev/null "$dump_environment_file" >/dev/null 2>&1
72
74
 
73
75
  else
74
- "$rvm_path/scripts/environment-convertor" "$dump_environment_type" "$(__rvm_environment_identifier)" > "$dump_environment_file"
76
+ "$rvm_path/scripts/environment-convertor" "$dump_environment_type" \
77
+ "$(__rvm_environment_identifier)" > "$dump_environment_file"
75
78
  if [[ "$?" -gt 0 && -f "$dump_environment_file" ]] ; then
76
79
  \rm -f "$dump_environment_file"
77
80
  fi
@@ -83,7 +86,8 @@ __rvm_dump_environment() {
83
86
 
84
87
  # Return a list of directories under a given base path.
85
88
  # Derived from rvm_ruby_string.
86
- __rvm_ruby_string_paths_under() {
89
+ __rvm_ruby_string_paths_under()
90
+ {
87
91
  local path part parts
88
92
 
89
93
  path="${1%/}" # Strip off any trailing slash
@@ -105,7 +109,8 @@ __rvm_ruby_string_paths_under() {
105
109
 
106
110
  # Query the rvm key-value database for a specific key
107
111
  # Allow overrides from user specifications in $rvm_path/config/user
108
- __rvm_db() {
112
+ __rvm_db()
113
+ {
109
114
  local value key variable
110
115
 
111
116
  key=${1:-""}
@@ -132,14 +137,16 @@ __rvm_db() {
132
137
 
133
138
  is_a_function() { type $1 | head -n 1 | \grep -q "function" ; }
134
139
 
135
- __rvm_quote_args() {
140
+ __rvm_quote_args()
141
+ {
136
142
  local quoted_string=""
137
143
 
138
144
  for quoted_argument in "$@"; do
139
145
 
140
146
  if printf "%s" "$quoted_argument" | \grep -vq "^[[:alnum:]]$"; then
141
147
 
142
- quoted_string="$quoted_string '$(printf "%s" "$quoted_argument" | sed "s/'/\'\\\'\'/g")'"
148
+ quoted_string="$quoted_string '$(printf "%s" "$quoted_argument" \
149
+ | sed "s/'/\'\\\'\'/g")'"
143
150
 
144
151
  else
145
152
  quoted_string="$quoted_string $quoted_argument"
@@ -151,8 +158,8 @@ __rvm_quote_args() {
151
158
  return 0
152
159
  }
153
160
 
154
- __rvm_quote_args_with_shift() {
155
-
161
+ __rvm_quote_args_with_shift()
162
+ {
156
163
  local shift_value="$1"; shift
157
164
 
158
165
  while [[ "$shift_value" -gt 0 && $# -gt 0 ]]; do
@@ -168,18 +175,20 @@ __rvm_quote_args_with_shift() {
168
175
  return 0
169
176
  }
170
177
 
171
- __rvm_warn_on_rubyopt() {
172
-
178
+ __rvm_warn_on_rubyopt()
179
+ {
173
180
  if [[ -n "${RUBYOPT:-""}" ]]; then
174
181
  "$rvm_path/scripts"/log "warn" \
175
- "Please note: You have the RUBYOPT environment variable set and this may interfere with normal rvm operations. We sugges unsetting it."
182
+ "Please note: You have the RUBYOPT environment variable set and this \
183
+ may interfere with normal rvm operations. We sugges unsetting it."
176
184
  return 1
177
185
  else
178
186
  return 0
179
187
  fi
180
188
  }
181
189
 
182
- __rvm_strings() {
190
+ __rvm_strings()
191
+ {
183
192
  local strings ruby_strings
184
193
 
185
194
  ruby_strings=($(echo ${rvm_ruby_args:-$rvm_ruby_string}))
@@ -194,8 +203,8 @@ __rvm_strings() {
194
203
  }
195
204
 
196
205
  # Push an item onto a given array.
197
- __rvm_push() {
198
-
206
+ __rvm_push()
207
+ {
199
208
  local array item
200
209
 
201
210
  array=$1 ; shift ; item=$2
@@ -209,9 +218,10 @@ __rvm_push() {
209
218
  }
210
219
 
211
220
  # Clean all *duplicate* items out of the path. (keep first occurrence of each)
212
- __rvm_clean_path() {
213
-
214
- PATH="$(printf "$PATH" | \tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' | \tr -s '\n' ':' | sed 's#:$##')"
221
+ __rvm_clean_path()
222
+ {
223
+ PATH="$(printf "$PATH" | \tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' \
224
+ | \tr -s '\n' ':' | sed 's#:$##')"
215
225
 
216
226
  export PATH
217
227
 
@@ -219,9 +229,11 @@ __rvm_clean_path() {
219
229
  }
220
230
 
221
231
  # Clean all rvm items out of the current working path.
222
- __rvm_remove_rvm_from_path() {
223
-
224
- PATH="$(printf "$PATH" | awk -v RS=: -v ORS=: "/${rvm_path//\//\/}/ {next} {print}" | sed -e 's#:$##')"
232
+ __rvm_remove_rvm_from_path()
233
+ {
234
+ PATH="$(printf "$PATH" \
235
+ | awk -v RS=: -v ORS=: "/${rvm_path//\//\/}/ {next} {print}" \
236
+ | sed -e 's#:$##')"
225
237
 
226
238
  export PATH
227
239
 
@@ -229,8 +241,8 @@ __rvm_remove_rvm_from_path() {
229
241
  }
230
242
 
231
243
  # Run a specified command and log it.
232
- __rvm_run() {
233
-
244
+ __rvm_run()
245
+ {
234
246
  local name log path command message
235
247
 
236
248
  name="${1:-""}"
@@ -282,8 +294,8 @@ __rvm_run() {
282
294
  }
283
295
 
284
296
  # Runs a command in a given env.
285
- __rvm_run_with_env() {
286
-
297
+ __rvm_run_with_env()
298
+ {
287
299
  local name environment command message log path
288
300
 
289
301
  name="${1:-""}"
@@ -300,7 +312,8 @@ __rvm_run_with_env() {
300
312
  fi
301
313
 
302
314
  if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
303
- "$rvm_path/scripts/log" "debug" "Executing: $command in environment "$environment""
315
+ "$rvm_path/scripts/log" "debug" \
316
+ "Executing: $command in environment $environment"
304
317
  fi
305
318
 
306
319
  path="${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string"
@@ -335,36 +348,45 @@ __rvm_run_with_env() {
335
348
 
336
349
  if [[ $result -gt 0 ]] ; then
337
350
  "$rvm_path/scripts/log" "error" \
338
- "Error running '$command' under $env_name, please check ${log/%log/error.log}"
351
+ "Error running '$command' under $env_name,\
352
+ \nplease check ${log/%log/error.log}"
339
353
  fi
340
354
 
341
355
  return ${result:-0}
342
356
  }
343
357
 
344
- __rvm_nuke_rvm_variables() {
358
+ __rvm_nuke_rvm_variables()
359
+ {
345
360
  unset rvm_head_flag $(env | awk -F= '/^rvm_/{print $1" "}')
346
361
  }
347
362
 
348
363
  # Unset ruby-specific variables
349
- __rvm_unset_ruby_variables() {
364
+ __rvm_unset_ruby_variables()
365
+ {
350
366
  unset rvm_ruby_flag $(env | awk -F= '/^rvm_ruby_/{printf $1" "}')
351
367
  }
352
368
 
353
369
  # TODO: Should be able to...
354
370
  # Unset both rvm variables as well as ruby-specific variables
355
- # Preserve gemset if 'rvm_sticky' is set (persist gemset unless clear is explicitely called).
356
- __rvm_cleanse_variables() {
357
-
371
+ # Preserve gemset if 'rvm_sticky' is set
372
+ # (persist gemset unless clear is explicitely called).
373
+ __rvm_cleanse_variables()
374
+ {
358
375
  __rvm_unset_ruby_variables
359
376
 
360
- if [[ ${rvm_sticky_flag:-0} -eq 1 ]] ; then export rvm_gemset_name ; else unset rvm_gemset_name ; fi
377
+ if [[ ${rvm_sticky_flag:-0} -eq 1 ]] ; then
378
+ export rvm_gemset_name
379
+ else
380
+ unset rvm_gemset_name
381
+ fi
361
382
 
362
383
  unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_import_flag rvm_export_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_configure_flags rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_sticky_flag rvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag rvm_docs_flag rvm_ruby_aliases rvm_patch_names rvm_clang_flag rvm_install_arguments rvm_dump_environment_flag rvm_ruby_alias
363
384
  }
364
385
 
365
386
  # Returns the first 1.8.7-compatible (partly) ruby for use
366
387
  # with things like rbx etc which require a ruby be installed.
367
- __rvm_18_compat_ruby() {
388
+ __rvm_18_compat_ruby()
389
+ {
368
390
  local rubies ruby_name
369
391
 
370
392
  rubies=($( cd "$rvm_path/rubies" ; find . -maxdepth 1 -mindepth 1 -type d ))
@@ -384,8 +406,8 @@ __rvm_18_compat_ruby() {
384
406
  return 0
385
407
  }
386
408
 
387
- __rvm_ensure_has_18_compat_ruby() {
388
-
409
+ __rvm_ensure_has_18_compat_ruby()
410
+ {
389
411
  if [[ -z "$(__rvm_18_compat_ruby)" ]]; then
390
412
  # TODO: install currently doesn't return the correct status.
391
413
  local compat_result=0
@@ -393,8 +415,9 @@ __rvm_ensure_has_18_compat_ruby() {
393
415
  if ! ( "$rvm_path/scripts/manage" install 1.8.7 ); then
394
416
 
395
417
  "$rvm_path/scripts/log" "fail" \
396
- "To proceed rvm requires a 1.8-compatible ruby is installed. We attempted to install 1.8.7 automatically but it failed.\
397
- Please install it manually (or a compatible alternative) to proceed."
418
+ "To proceed rvm requires a 1.8-compatible ruby is installed.\
419
+ \nWe attempted to install 1.8.7 automatically but it failed.\
420
+ \nPlease install it manually (or a compatible alternative) to proceed."
398
421
 
399
422
  compat_result=1
400
423
 
@@ -409,8 +432,8 @@ __rvm_ensure_has_18_compat_ruby() {
409
432
 
410
433
  # Cleans up temp folders for a given prefix ($1),
411
434
  # typically the current process id.
412
- __rvm_cleanup_temp_for() {
413
-
435
+ __rvm_cleanup_temp_for()
436
+ {
414
437
  result=$? # Capture last command status
415
438
 
416
439
  [[ -z "${1:-""}" ]] && return 1
@@ -424,8 +447,8 @@ __rvm_cleanup_temp_for() {
424
447
  return $result
425
448
  }
426
449
 
427
- __rvm_set_rvmrc() {
428
-
450
+ __rvm_set_rvmrc()
451
+ {
429
452
  local flags
430
453
 
431
454
  if [[ "$HOME" != "$PWD" ]] ; then
@@ -446,8 +469,9 @@ __rvm_set_rvmrc() {
446
469
  local identifier=$(__rvm_environment_identifier)
447
470
 
448
471
  printf "
449
- if [[ -d \"\$rvm_path/environments\" && -s \"\$rvm_path/environments/$identifier\" ]] ; then
450
- \\. \"\$rvm_path/environments/$identifier\"
472
+ if [[ -d \"\${rvm_path:-\$HOME/.rvm}/environments\" \\
473
+ && -s \"\${rvm_path:-\$HOME/.rvm}/environments/$identifier\" ]] ; then
474
+ \\. \"\${rvm_path:-\$HOME/.rvm}/environments/$identifier\"
451
475
  else
452
476
  rvm --create $flags \"$identifier\"
453
477
  fi
@@ -455,11 +479,13 @@ fi
455
479
 
456
480
  else
457
481
  "$rvm_path/scripts/log" "error" \
458
- ".rvmrc cannot be set in your home directory. \n The home .rvmrc is for global rvm settings only."
482
+ ".rvmrc cannot be set in your home directory.\
483
+ \nThe home .rvmrc is for global rvm settings only."
459
484
  fi
460
485
  }
461
- __rvm_load_rvmrc() {
462
486
 
487
+ __rvm_load_rvmrc()
488
+ {
463
489
  [[ ${rvm_ignore_rvmrc:-0} -eq 1 ]] && return 0
464
490
 
465
491
  for rvmrc in /etc/rvmrc $HOME/.rvmrc ; do
@@ -469,7 +495,9 @@ __rvm_load_rvmrc() {
469
495
  if \grep -q '^\s*rvm .*$' $rvmrc ; then
470
496
 
471
497
  "$rvm_path/scripts/log" "error" \
472
- "$rvmrc is for rvm settings only.\nrvm CLI may NOT be called from within $rvmrc. \nSkipping the loading of $rvmrc"
498
+ "$rvmrc is for rvm settings only.\
499
+ \nrvm CLI may NOT be called from within $rvmrc.\
500
+ \nSkipping the loading of $rvmrc"
473
501
 
474
502
  return 1
475
503
 
@@ -487,11 +515,13 @@ __rvm_load_rvmrc() {
487
515
  }
488
516
 
489
517
  # Wrap the specified ruby code file in a Benchmark.bmbm block and execute it.
490
- __rvm_benchmark() {
491
-
518
+ __rvm_benchmark()
519
+ {
492
520
  local old_rvm_ruby_string
493
521
 
494
- code="require \"benchmark\" \n Benchmark.bmbm do |benchmark| \n benchmark.report(\"${rvm_ruby_file}\") do \n"
522
+ code="require \"benchmark\" \n \
523
+ Benchmark.bmbm do |benchmark| \n \
524
+ benchmark.report(\"${rvm_ruby_file}\") do \n"
495
525
 
496
526
  printf "\n$code" > "${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
497
527
 
@@ -509,7 +539,8 @@ __rvm_benchmark() {
509
539
 
510
540
  if [[ ${rvm_debug_flag:0} -gt 0 ]] ; then
511
541
 
512
- printf "\n${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb:\n$(cat ${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb)"
542
+ printf "\n${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb:\n\
543
+ $(cat ${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb)"
513
544
 
514
545
  fi
515
546
 
@@ -517,7 +548,8 @@ __rvm_benchmark() {
517
548
 
518
549
  old_rvm_ruby_string=$rvm_ruby_string
519
550
 
520
- # TODO: We can likely do this in a subshell in order to preserve the original environment?
551
+ # TODO: We can likely do this in a subshell in order to
552
+ # preserve the original environment?
521
553
 
522
554
  unset rvm_ruby_string
523
555
 
@@ -532,13 +564,14 @@ __rvm_benchmark() {
532
564
  }
533
565
 
534
566
  # Loop over the currently installed rubies and refresh their binscripts.
535
- __rvm_bin_scripts() {
536
-
567
+ __rvm_bin_scripts()
568
+ {
537
569
  for rvm_ruby_binary in "$rvm_path/rubies"/*/bin/ruby ; do
538
570
 
539
571
  if [[ -x "$rvm_ruby_binary" ]] ; then
540
572
 
541
- rvm_ruby_string=$(dirname "$rvm_ruby_binary" | xargs dirname | xargs basename)
573
+ rvm_ruby_string=$(dirname "$rvm_ruby_binary" \
574
+ | xargs dirname | xargs basename)
542
575
 
543
576
  __rvm_select
544
577
 
@@ -552,28 +585,28 @@ __rvm_bin_scripts() {
552
585
  }
553
586
 
554
587
  # Write the bin/ wrapper script for currently selected ruby.
555
- # TODO: Adjust binscript to be able to handle all rubies not just the standard interpreteres.
556
- __rvm_bin_script() {
557
-
588
+ # TODO: Adjust binscript to be able to handle all rubies,
589
+ # not just the standard interpreteres.
590
+ __rvm_bin_script()
591
+ {
558
592
  "$rvm_path/scripts/wrapper" "$rvm_ruby_string"
559
593
 
560
594
  return $?
561
595
  }
562
596
 
563
597
  # Add bin path if not present
564
- __rvm_conditionally_add_bin_path() {
565
-
566
- if echo "${PATH//:/ }" | \grep -vqF "${rvm_bin_path:-"$rvm_path/bin"} " ; then
567
-
568
- if [[ "${rvm_ruby_string:-"system"}" != "system" ]] ; then
569
-
570
- PATH="${rvm_bin_path:-"$rvm_path/bin"}:$PATH"
571
-
572
- else
573
-
574
- PATH="$PATH:${rvm_bin_path:-"$rvm_path/bin"}"
575
-
576
- fi
598
+ __rvm_conditionally_add_bin_path()
599
+ {
600
+ if printf "${PATH//:/ }" | \grep -vqF "${rvm_bin_path:-"$rvm_path/bin"} " ; then
601
+
602
+ case "${rvm_ruby_string:-"system"}" in
603
+ system)
604
+ PATH="$PATH:${rvm_bin_path:-"$rvm_path/bin"}"
605
+ ;;
606
+ *)
607
+ PATH="${rvm_bin_path:-"$rvm_path/bin"}:$PATH"
608
+ ;;
609
+ esac
577
610
 
578
611
  builtin hash -r
579
612
  fi
@@ -583,8 +616,8 @@ __rvm_conditionally_add_bin_path() {
583
616
 
584
617
  # Reset any rvm gathered information about the system and its state.
585
618
  # rvm will refresh the stored information the next time it is called after reset.
586
- __rvm_reset() {
587
-
619
+ __rvm_reset()
620
+ {
588
621
  local flag flags file files config configs variable
589
622
 
590
623
  __rvm_remove_rvm_from_path ; __rvm_conditionally_add_bin_path
@@ -603,11 +636,17 @@ __rvm_reset() {
603
636
 
604
637
  for file in system default ; do
605
638
 
606
- [[ -f "$rvm_path/${file}" ]] && \rm -f "$rvm_path/${file}"
639
+ if [[ -f "$rvm_path/${file}" ]] ; then
640
+ \rm -f "$rvm_path/${file}"
641
+ fi
607
642
 
608
- [[ -f "$rvm_path/config/${file}" ]] && \rm -f "$rvm_path/config/${file}"
643
+ if [[ -f "$rvm_path/config/${file}" ]] ; then
644
+ \rm -f "$rvm_path/config/${file}"
645
+ fi
609
646
 
610
- [[ -f "$rvm_path/environments/${file}" ]] && \rm -f "$rvm_path/environments/${file}"
647
+ if [[ -f "$rvm_path/environments/${file}" ]] ; then
648
+ \rm -f "$rvm_path/environments/${file}"
649
+ fi
611
650
 
612
651
  done
613
652
 
@@ -624,7 +663,9 @@ __rvm_reset() {
624
663
 
625
664
  done
626
665
 
627
- files=(ruby gem rake irb $(cd "${rvm_bin_path:-"$rvm_path/bin"}" ; find . -iname 'default*' --mindepth 1 --maxdepth 1 -type f | sed -e 's#./##g'))
666
+ files=(ruby gem rake irb $(cd "${rvm_bin_path:-"$rvm_path/bin"}" ; \
667
+ find . -mindepth 1 -maxdepth 1 -iname 'default*' -type f \
668
+ | sed -e 's#./##g'))
628
669
 
629
670
  for file in "${files[@]}"; do
630
671
 
@@ -640,12 +681,14 @@ __rvm_reset() {
640
681
  }
641
682
 
642
683
  # Implode removes the entire rvm installation under $rvm_path.
643
- __rvm_implode() {
644
-
684
+ __rvm_implode()
685
+ {
645
686
  while : ; do
646
687
 
647
688
  "$rvm_path/scripts/log" "warn" \
648
- "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')"
689
+ "Are you SURE you wish for rvm to implode?\
690
+ \nThis will recursively remove $rvm_path ?\
691
+ \n(type 'yes' or 'no')> "
649
692
 
650
693
  read response
651
694
 
@@ -689,8 +732,8 @@ __rvm_implode() {
689
732
  }
690
733
 
691
734
  # Output the current ruby's rvm source path.
692
- __rvm_source_dir() {
693
-
735
+ __rvm_source_dir()
736
+ {
694
737
  if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi
695
738
 
696
739
  if [[ -z "$rvm_ruby_src_path" ]] ; then
@@ -708,7 +751,8 @@ __rvm_source_dir() {
708
751
  }
709
752
 
710
753
  # Initialize rvm, ensuring that the path and directories are as expected.
711
- __rvm_initialize() {
754
+ __rvm_initialize()
755
+ {
712
756
  rvm_ruby_load_path="."
713
757
  rvm_ruby_require=""
714
758
 
@@ -722,28 +766,36 @@ __rvm_initialize() {
722
766
  }
723
767
 
724
768
  # Update rubygems or binscripts based on CLI selection.
725
- __rvm_update() {
769
+ __rvm_update()
770
+ {
726
771
  (
727
772
  builtin cd "$rvm_path"
728
773
 
729
- if [[ ${rvm_head_flag:-0} -eq 1 || ${rvm_self_flag:-0} -eq 1 || "update" = "${rvm_action:-""}" || ${rvm_update_flag:-0} -eq 1 ]] ; then
774
+ if [[ ${rvm_head_flag:-0} -eq 1 || ${rvm_self_flag:-0} -eq 1 \
775
+ || "update" = "${rvm_action:-""}" || ${rvm_update_flag:-0} -eq 1 ]] ; then
730
776
  __rvm_version
731
777
  __rvm_update_rvm
732
778
  fi
733
779
 
734
- [[ ${rvm_bin_flag:-0} -eq 1 ]] && __rvm_bin_scripts
780
+ if [[ ${rvm_bin_flag:-0} -eq 1 ]] ; then
781
+ __rvm_bin_scripts
782
+ fi
735
783
 
736
784
  # Update to the latest rubygems.
737
- [[ ${rvm_rubygems_flag:-0} -eq 1 ]] && "$rvm_path/scripts/rubygems" current
738
-
785
+ if [[ ${rvm_rubygems_flag:-0} -eq 1 ]] ; then
786
+ "$rvm_path/scripts/rubygems" current
787
+ fi
739
788
  )
740
- unset rvm_update_flag rvm_action rvm_self_flag rvm_ruby_revision rvm_bin_flag rvm_rubygems_flag
789
+ unset rvm_update_flag rvm_action rvm_self_flag \
790
+ rvm_ruby_revision rvm_bin_flag rvm_rubygems_flag
791
+
741
792
  return 0
742
793
  }
743
794
 
744
795
  # Update rvm using rubygems
745
796
  # If --head was specified, update from git repository master branch.
746
- __rvm_update_rvm() {
797
+ __rvm_update_rvm()
798
+ {
747
799
  (
748
800
  if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}" ]] ; then
749
801
  \mkdir -p "${rvm_src_path:-"$rvm_path/src"}"
@@ -767,18 +819,24 @@ __rvm_update_rvm() {
767
819
  builtin cd rvm/ && ./scripts/install
768
820
  fi
769
821
  else
770
- stable_version="$(curl -s http://rvm.beginrescueend.com/releases/stable-version.txt)"
822
+ version_url="http://rvm.beginrescueend.com/releases/stable-version.txt"
823
+
824
+ stable_version="$(curl -s $version_url)"
771
825
 
772
826
  __rvm_run "fetch" \
773
- "$rvm_path/scripts/fetch 'http://rvm.beginrescueend.com/releases/rvm-${stable_version}.tar.gz'" \
827
+ "$rvm_path/scripts/fetch \
828
+ 'http://rvm.beginrescueend.com/releases/rvm-${stable_version}.tar.gz'" \
774
829
  "fetching rvm-${stable_version}.tar.gz"
775
830
 
776
831
  __rvm_run "extract" \
777
- "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/rvm-${stable_version}.tar.gz\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \
832
+ "gunzip < \
833
+ \"${rvm_archives_path:-"$rvm_path/archives"}/rvm-${stable_version}.tar.gz\" \
834
+ | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \
778
835
  "Extracting rvm-${stable_version}.tar.gz ..."
779
836
 
780
837
  __rvm_run "install" \
781
- "builtin cd ${rvm_src_path:-"$rvm_path/src"}/rvm-${stable_version}/ ; ./install" \
838
+ "builtin cd ${rvm_src_path:-"$rvm_path/src"}/rvm-${stable_version}/;\
839
+ ./install" \
782
840
  "Installing rvm-${stable_version}..."
783
841
  fi
784
842
  )
@@ -788,8 +846,11 @@ __rvm_update_rvm() {
788
846
  return 0
789
847
  }
790
848
 
791
- __rvm_reboot() {
792
- "$rvm_path/scripts/log" "warn" "Do you wish to reboot rvm? ('yes', or 'no')"
849
+ __rvm_reboot()
850
+ {
851
+ "$rvm_path/scripts/log" "warn" \
852
+ "Do you wish to reboot rvm?\
853
+ \n('yes', or 'no')> "
793
854
 
794
855
  local response="no"
795
856
 
@@ -821,7 +882,8 @@ __rvm_reboot() {
821
882
  }
822
883
 
823
884
  # Create the irbrc for the currently selected ruby installation.
824
- __rvm_irbrc() {
885
+ __rvm_irbrc()
886
+ {
825
887
  if [[ -d "$rvm_ruby_home" && ! -s "$rvm_ruby_irbrc" ]] ; then
826
888
  \cp "$rvm_path/scripts/irbrc" "$rvm_ruby_irbrc"
827
889
  fi
@@ -829,95 +891,172 @@ __rvm_irbrc() {
829
891
  }
830
892
 
831
893
  # Save or restore the rvm's state. This is a toggle action.
832
- # Meant for use before and after an operation that might reset the currently selected ruby.
833
- __rvm_state() {
894
+ # Meant for use before and after an operation that might reset
895
+ # the currently selected ruby.
896
+ # TODO: Determine if we should a) yank this out or b) actually use it :)
897
+ __rvm_state()
898
+ {
834
899
  if [[ -z "$rvm_state" ]] ; then
900
+
835
901
  rvm_state="$(__rvm_environment_identifier)"
902
+
836
903
  rvm_state="${rvm_state:-"system"}"
904
+
837
905
  if [[ -n "$1" ]]; then
906
+
838
907
  rvm_ruby_string="$1"
908
+
839
909
  __rvm_select
910
+
840
911
  __rvm_use
912
+
841
913
  fi
914
+
842
915
  else
916
+
843
917
  rvm_ruby_string="$rvm_state"
918
+
844
919
  __rvm_select
920
+
845
921
  __rvm_use
922
+
846
923
  unset rvm_state
924
+
847
925
  fi
848
926
 
849
927
  return 0
850
928
  }
851
929
 
852
930
  # Output an inspection of selected 'binary' scripts, based on CLI selection.
853
- __rvm_inspect() {
854
-
931
+ __rvm_inspect()
932
+ {
855
933
  for binary in $rvm_ruby_args ; do
934
+
856
935
  actual_file="$(unset -f gem ; command -v gem )"
857
936
 
858
937
  "$rvm_path/scripts/log" "info" "$actual_file:"
859
938
 
860
- if [[ ${rvm_shebang_flag:-0} -eq 1 ]] ; then \head -n 1 < "$actual_file" ; fi
861
- if [[ ${rvm_env_flag:-0} -eq 1 ]] ; then \awk '/ENV/' < "$actual_file" ; fi
862
- if [[ ${rvm_path_flag:-0} -eq 1 ]] ; then \awk '/PATH/' < "$actual_file" ; fi
863
- if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then \head -n 5 < "$actual_file" ; fi
864
- if [[ ${rvm_tail_flag:-0} -eq 1 ]] ; then \tail -n 5 < "$actual_file" ; fi
865
- if [[ ${rvm_all_flag:-0} -eq 1 ]] ; then \cat $actual_file ; fi
939
+ if [[ ${rvm_shebang_flag:-0} -eq 1 ]] ; then
940
+ \head -n 1 < "$actual_file"
941
+ fi
942
+
943
+ if [[ ${rvm_env_flag:-0} -eq 1 ]] ; then
944
+ \awk '/ENV/' < "$actual_file"
945
+ fi
946
+
947
+ if [[ ${rvm_path_flag:-0} -eq 1 ]] ; then
948
+ \awk '/PATH/' < "$actual_file"
949
+ fi
950
+
951
+ if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
952
+ \head -n 5 < "$actual_file"
953
+ fi
954
+
955
+ if [[ ${rvm_tail_flag:-0} -eq 1 ]] ; then
956
+ \tail -n 5 < "$actual_file"
957
+ fi
958
+
959
+ if [[ ${rvm_all_flag:-0} -eq 1 ]] ; then
960
+ \cat $actual_file
961
+ fi
962
+
866
963
  done
867
964
 
868
965
  return 0
869
966
  }
870
967
 
871
968
  # Attempt to override the Darwin build settings for rubies
872
- # This should only be used in extreme edge cases that will not work via the default way.
873
- __rvm_make_flags() {
969
+ # This should only be used in extreme edge cases that
970
+ # will not work via the default way.
971
+ __rvm_make_flags()
972
+ {
874
973
  # This is only an issue with Darwin :/
875
974
  if [[ "Darwin" = "$(uname)" ]] ; then
876
975
  # \ls /usr/lib/gcc/x86_64-apple-darwin10
877
976
 
878
977
  # Set the build & host type
879
978
  if [[ "Power Macintosh" = "$(sysctl -n hw.machine)" ]] ; then
979
+
880
980
  : # Do nothing ?
881
- elif [[ "$(sysctl -n hw.cpu64bit_capable)" = 1 || "$(sysctl -n hw.optional.x86_64)" = 1 ]] ; then
981
+
982
+ elif [[ "$(sysctl -n hw.cpu64bit_capable)" = 1 \
983
+ || "$(sysctl -n hw.optional.x86_64)" = 1 ]] ; then
984
+
882
985
  # 64 bit capable
986
+
883
987
  if [[ "-arch x86_64" = "${rvm_archflags:-""}" ]] ; then
884
- rvm_configure_flags="${rvm_configure_flags} --build=x86_64-apple-darwin$(uname -r) --host=x86_64-apple-darwin$(uname -r)"
988
+
989
+ rvm_configure_flags="${rvm_configure_flags} \
990
+ --build=x86_64-apple-darwin$(uname -r) \
991
+ --host=x86_64-apple-darwin$(uname -r)"
992
+
885
993
  elif [[ "-arch i386" = "${rvm_archflags:-""}" ]] ; then
886
- rvm_configure_flags="${rvm_configure_flags} --build=i386-apple-darwin$(uname -r) --host=i386-apple-darwin$(uname -r)"
994
+
995
+ rvm_configure_flags="${rvm_configure_flags} \
996
+ --build=i386-apple-darwin$(uname -r) \
997
+ --host=i386-apple-darwin$(uname -r)"
998
+
887
999
  else
1000
+
888
1001
  rvm_archflags="-arch x86_64"
889
- rvm_configure_flags="${rvm_configure_flags} --build=x86_64-apple-darwin$(uname -r) --host=x86_64-apple-darwin$(uname -r)"
1002
+
1003
+ rvm_configure_flags="${rvm_configure_flags} \
1004
+ --build=x86_64-apple-darwin$(uname -r) \
1005
+ --host=x86_64-apple-darwin$(uname -r)"
1006
+
890
1007
  fi
1008
+
891
1009
  fi
892
1010
 
893
1011
  if [[ -n "${rvm_archflags:-""}" ]] ; then
1012
+
894
1013
  ARCHFLAGS="$rvm_archflags" ; export ARCHFLAGS
1014
+
895
1015
  # Use the latest sdk available.
896
1016
  if [[ -z "${rvm_sdk:-""}" ]] ; then
897
- rvm_sdk="$(/usr/bin/basename -a /Developer/SDKs/* | awk '/^M/' | \sort | \tail -n 1)"
1017
+
1018
+ rvm_sdk="$(/usr/bin/basename -a /Developer/SDKs/* \
1019
+ | awk '/^M/' | \sort | \tail -n 1)"
1020
+
898
1021
  fi
899
- CFLAGS="${CFLAGS:-"-isysroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}" ; export CFLAGS
900
- LDFLAGS="${LDFLAGS:-"-Wl,-syslibroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}" ; export LDFLAGS
901
- # CXXFLAGS="-mmacosx-version-min="$(sw_vers -productVersion | awk -F'.' '{print $1"."$2}')" -isysroot /Developer/SDKs/$rvm_sdk " ; export CXXFLAGS
1022
+
1023
+ CFLAGS="${CFLAGS:-"-isysroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}"
1024
+
1025
+ export CFLAGS
1026
+
1027
+ LDFLAGS="${LDFLAGS:-"-Wl,-syslibroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}"
1028
+
1029
+ export LDFLAGS
1030
+
1031
+ # CXXFLAGS="-mmacosx-version-min="$(sw_vers -productVersion \
1032
+ # | awk -F'.' '{print $1"."$2}')" -isysroot /Developer/SDKs/$rvm_sdk "
1033
+ # export CXXFLAGS
1034
+
902
1035
  fi
903
1036
  fi
904
1037
 
905
1038
  return 0
906
1039
  }
907
1040
 
908
- __rvm_mono_env() {
909
- export DYLD_LIBRARY_PATH="${rvm_usr_path:-"$rvm_path/usr"}/lib:$DYLD_LIBRARY_PATH"
910
- export C_INCLUDE_PATH="${rvm_usr_path:-"$rvm_path/usr"}/include:$C_INCLUDE_PATH"
911
- export ACLOCAL_PATH="${rvm_usr_path:-"$rvm_path/usr"}/share/aclocal"
912
- export ACLOCAL_FLAGS="-I $ACLOCAL_PATH"
913
- export PKG_CONFIG_PATH="${rvm_usr_path:-"$rvm_path/usr"}/lib/pkgconfig:$PKG_CONFIG_PATH"
1041
+ __rvm_mono_env()
1042
+ {
1043
+ DYLD_LIBRARY_PATH="${rvm_usr_path:-"$rvm_path/usr"}/lib:$DYLD_LIBRARY_PATH"
1044
+ C_INCLUDE_PATH="${rvm_usr_path:-"$rvm_path/usr"}/include:$C_INCLUDE_PATH"
1045
+ ACLOCAL_PATH="${rvm_usr_path:-"$rvm_path/usr"}/share/aclocal"
1046
+ ACLOCAL_FLAGS="-I $ACLOCAL_PATH"
1047
+ PKG_CONFIG_PATH="${rvm_usr_path:-"$rvm_path/usr"}/lib/pkgconfig:$PKG_CONFIG_PATH"
1048
+
1049
+ export DYLD_LIBRARY_PATH C_INCLUDE_PATH ACLOCAL_PATH ACLOCAL_FLAGS PKG_CONFIG_PATH
1050
+
914
1051
  PATH="${rvm_usr_path:-"$rvm_path/usr"}/bin:$PATH"
1052
+
915
1053
  builtin hash -r
916
1054
 
917
1055
  return 0
918
1056
  }
919
1057
 
920
- __rvm_become() {
1058
+ __rvm_become()
1059
+ {
921
1060
  local string="$1"
922
1061
 
923
1062
  [[ -n "$string" ]] && rvm_ruby_string="$string"
@@ -927,8 +1066,9 @@ __rvm_become() {
927
1066
  return 0
928
1067
  }
929
1068
 
930
- __rvm_ensure_has_environment_files() {
931
- local environment_id file_name directory_name wrapper_identifier variable value
1069
+ __rvm_ensure_has_environment_files()
1070
+ {
1071
+ local environment_id file_name directory identifier variable value variables
932
1072
 
933
1073
  environment_id="$(__rvm_environment_identifier)"
934
1074
 
@@ -938,36 +1078,45 @@ __rvm_ensure_has_environment_files() {
938
1078
 
939
1079
  \mkdir -p "$rvm_path/environments"
940
1080
 
941
- echo "export PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path:-"$rvm_path/bin"}:\$PATH\"" > "$file_name"
1081
+ printf "export PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path:-"$rvm_path/bin"}:\$PATH\"\n" \
1082
+ > "$file_name"
942
1083
 
943
- for variable in rvm_path RUBY_VERSION GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME IRBRC rvm_ruby_string rvm_gemset_name MAGLEV_HOME ; do
1084
+ for variable in rvm_path RUBY_VERSION GEM_HOME GEM_PATH BUNDLE_PATH \
1085
+ MY_RUBY_HOME IRBRC rvm_ruby_string rvm_gemset_name MAGLEV_HOME ; do
944
1086
 
945
1087
  eval "export $variable"
946
1088
  eval "value=\${${variable}:-""}"
947
1089
 
948
1090
  if [[ -n "$value" ]] ; then
949
- printf "${variable}='$value'\nexport ${variable}\n" >> "$file_name"
1091
+
1092
+ printf "${variable}='$value'\nexport ${variable}\n" \
1093
+ >> "$file_name"
1094
+
950
1095
  else
951
- printf "unset ${variable}\n" >> "$file_name"
1096
+
1097
+ printf "unset ${variable}\n" \
1098
+ >> "$file_name"
1099
+
952
1100
  fi
953
1101
 
954
1102
  done
955
1103
  fi
956
1104
 
957
1105
  # Next, ensure we have default wrapper files. Also, prevent it from recursing.
958
- if [[ ${rvm_create_default_wrappers:-0} -eq 1 || ! -f "$rvm_path/wrappers/$environment_id/ruby" ]] ; then
1106
+ if [[ ${rvm_create_default_wrappers:-0} -eq 1 \
1107
+ || ! -f "$rvm_path/wrappers/$environment_id/ruby" ]] ; then
959
1108
 
960
1109
  # We need to generate wrappers for both the default gemset and the global gemset.
961
- for wrapper_identifier in "$environment_id" "${environment_id//@*/}@global" ; do
1110
+ for identifier in "$environment_id" "${environment_id//@*/}@global" ; do
962
1111
 
963
1112
  rvm_create_default_wrappers=1
964
1113
 
965
- directory_name="$rvm_path/wrappers/$wrapper_identifier"
1114
+ directory="$rvm_path/wrappers/$identifier"
966
1115
 
967
- if [[ ! -L "$directory_name" && ! -d "$directory_name" ]]; then
968
- \mkdir -p "$directory_name"
1116
+ if [[ ! -L "$directory" && ! -d "$directory" ]]; then
1117
+ \mkdir -p "$directory"
969
1118
 
970
- "$rvm_path/scripts/wrapper" "$wrapper_identifier" &> /dev/null
1119
+ "$rvm_path/scripts/wrapper" "$identifier" &> /dev/null
971
1120
  fi
972
1121
 
973
1122
  done
@@ -979,17 +1128,21 @@ __rvm_ensure_has_environment_files() {
979
1128
  }
980
1129
 
981
1130
  # Strip whitespace and normalize it all.
982
- __rvm_strip() {
1131
+ __rvm_strip()
1132
+ {
983
1133
  sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]\{1,\}/ /g'
984
1134
  return $?
985
1135
  }
986
1136
 
987
- __rvm_using_gemset_globalcache() {
988
- "$rvm_path/scripts/db" "$rvm_path/config/user" "use_gemset_globalcache" | \grep -q '^true$'
1137
+ __rvm_using_gemset_globalcache()
1138
+ {
1139
+ "$rvm_path/scripts/db" "$rvm_path/config/user" \
1140
+ "use_gemset_globalcache" | \grep -q '^true$'
989
1141
  return $?
990
1142
  }
991
1143
 
992
- __rvm_current_gemcache_dir() {
1144
+ __rvm_current_gemcache_dir()
1145
+ {
993
1146
  if __rvm_using_gemset_globalcache; then
994
1147
  echo "$rvm_gems_cache_path"
995
1148
  else
@@ -998,22 +1151,27 @@ __rvm_current_gemcache_dir() {
998
1151
  return 0
999
1152
  }
1000
1153
 
1001
- __rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything() {
1002
- for index in {1..750} ; do sleep 0.25 ; echo -n '.' ; done ; printf "%d" 0x2A ; echo
1154
+ __rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything()
1155
+ {
1156
+ for index in {1..750} ; do sleep 0.25 ; echo -n '.' ; done ; printf "%d" 0x2A
1157
+ echo
1003
1158
  return 0
1004
1159
  }
1005
1160
 
1006
- __rvm_ultimate_question() {
1161
+ __rvm_ultimate_question()
1162
+ {
1007
1163
  printf "
1008
1164
  I do not know the Ultimate Question,
1009
1165
  however I can help you build a more
1010
1166
  powerful Ruby which can compute the
1011
1167
  Ultimate Question.
1168
+
1012
1169
  "
1013
1170
  return 0
1014
1171
  }
1015
1172
 
1016
- __rvm_load_env_file() {
1173
+ __rvm_load_env_file()
1174
+ {
1017
1175
  local string="$1"
1018
1176
  if [[ -f "$rvm_path/environments/$string" ]]; then
1019
1177
  # Restore the path to it's state minus rvm
@@ -1032,51 +1190,63 @@ __rvm_load_env_file() {
1032
1190
  return 0
1033
1191
  }
1034
1192
 
1035
- __rvm_md5_for() {
1193
+ __rvm_md5_for()
1194
+ {
1036
1195
  if command -v md5 > /dev/null; then
1037
1196
  echo "$1" | md5
1038
1197
  elif command -v md5sum > /dev/null ; then
1039
1198
  echo "$1" | md5sum | awk '{print $1}'
1040
1199
  else
1041
- "$rvm_path/scripts/log" "error" "Neither md5 nor md5sum were found in the PATH"
1200
+ "$rvm_path/scripts/log" "error" \
1201
+ "Neither md5 nor md5sum were found in the PATH"
1042
1202
  return 1
1043
1203
  fi
1044
1204
 
1045
1205
  return 0
1046
1206
  }
1047
1207
 
1048
- __rvm_rvmrc_key() {
1208
+ __rvm_rvmrc_key()
1209
+ {
1049
1210
  __rvm_md5_for "$1"
1050
1211
  return $?
1051
1212
  }
1052
1213
 
1053
- __rvm_reset_rvmrc_trust() {
1214
+ __rvm_reset_rvmrc_trust()
1215
+ {
1054
1216
  touch "$rvm_path/config/rvmrcs"
1055
- "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" "$(__rvm_rvmrc_key "$1")" "delete" >/dev/null 2>&1
1217
+ "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
1218
+ "$(__rvm_rvmrc_key "$1")" "delete" >/dev/null 2>&1
1056
1219
  return $?
1057
1220
  }
1058
1221
 
1059
- __rvm_trust_rvmrc() {
1222
+ __rvm_trust_rvmrc()
1223
+ {
1060
1224
  touch "$rvm_path/config/rvmrcs"
1061
1225
  __rvm_reset_rvmrc_trust "$1"
1062
- "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" "$(__rvm_rvmrc_key "$1")" "1" >/dev/null 2>&1
1226
+ "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
1227
+ "$(__rvm_rvmrc_key "$1")" "1" >/dev/null 2>&1
1063
1228
  return $?
1064
1229
  }
1065
1230
 
1066
- __rvm_untrust_rvmrc() {
1231
+ __rvm_untrust_rvmrc()
1232
+ {
1067
1233
  touch "$rvm_path/config/rvmrcs"
1068
1234
  __rvm_reset_rvmrc_trust "$1"
1069
- "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" "$(__rvm_rvmrc_key "$1")" "0" >/dev/null 2>&1
1235
+ "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
1236
+ "$(__rvm_rvmrc_key "$1")" "0" >/dev/null 2>&1
1070
1237
  return $?
1071
1238
  }
1072
1239
 
1073
- __rvm_rvmrc_stored_trust() {
1240
+ __rvm_rvmrc_stored_trust()
1241
+ {
1074
1242
  touch "$rvm_path/config/rvmrcs"
1075
- "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" "$(__rvm_rvmrc_key "$1")"
1243
+ "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
1244
+ "$(__rvm_rvmrc_key "$1")"
1076
1245
  return $?
1077
1246
  }
1078
1247
 
1079
- __rvm_rvmrc_tools() {
1248
+ __rvm_rvmrc_tools()
1249
+ {
1080
1250
  local rvmrc_action="$1"
1081
1251
  [[ $# -gt 0 ]] && shift
1082
1252
  local rvmrc_path="$(builtin cd "${1:-$PWD}" >/dev/null 2>&1; pwd)/.rvmrc"
@@ -1104,7 +1274,8 @@ __rvm_rvmrc_tools() {
1104
1274
  fi
1105
1275
  ;;
1106
1276
  load)
1107
- rvm_rvmrc_cwd="" rvm_trust_rvmrcs=1 __rvm_project_rvmrc "$(dirname "$rvmrc_path")"
1277
+ rvm_rvmrc_cwd="" rvm_trust_rvmrcs=1 \
1278
+ __rvm_project_rvmrc "$(dirname "$rvmrc_path")"
1108
1279
  ;;
1109
1280
  *)
1110
1281
  echo "Usage: rvm rvmrc {trust,untrust,trusted,load,reset}"
@@ -1114,7 +1285,8 @@ __rvm_rvmrc_tools() {
1114
1285
  return $?
1115
1286
  }
1116
1287
 
1117
- __rvm_check_rvmrc_trustworthiness() {
1288
+ __rvm_check_rvmrc_trustworthiness()
1289
+ {
1118
1290
  # Trust when they have the flag... of doom!
1119
1291
  [[ -z "$1" || "$rvm_trust_rvmrcs" = "1" ]] && return 0
1120
1292
  value="$(__rvm_rvmrc_stored_trust "$1")"
@@ -1126,7 +1298,8 @@ __rvm_check_rvmrc_trustworthiness() {
1126
1298
  return $?
1127
1299
  }
1128
1300
 
1129
- __rvm_ask_to_trust() {
1301
+ __rvm_ask_to_trust()
1302
+ {
1130
1303
 
1131
1304
  local trusted value
1132
1305
 
@@ -1179,7 +1352,8 @@ $(cat $1)
1179
1352
 
1180
1353
  # Checks the rvmrc for the given directory. Note that if
1181
1354
  # argument is passed, it will be used instead of pwd.
1182
- __rvm_project_rvmrc() {
1355
+ __rvm_project_rvmrc()
1356
+ {
1183
1357
  local cwd
1184
1358
 
1185
1359
  # Get the first argument or the pwd.
@@ -1239,7 +1413,8 @@ __rvm_project_rvmrc() {
1239
1413
  return $?
1240
1414
  }
1241
1415
 
1242
- __rvm_record_install() {
1416
+ __rvm_record_install()
1417
+ {
1243
1418
 
1244
1419
  local recorded_ruby_name rvm_install_record_file rvm_install_command
1245
1420
 
@@ -1249,13 +1424,14 @@ __rvm_record_install() {
1249
1424
 
1250
1425
  rvm_install_record_file="$rvm_path/config/installs"
1251
1426
 
1252
- rvm_install_command="$(echo "$recorded_ruby_name $rvm_install_arguments" | __rvm_strip)"
1427
+ rvm_install_command=$(printf "$recorded_ruby_name $rvm_install_arguments\n")
1253
1428
 
1254
1429
  \touch "$rvm_install_record_file"
1255
1430
 
1256
1431
  \rm -f "$rvm_install_record_file.tmp"
1257
1432
 
1258
- \grep -v "^$recorded_ruby_name " < "$rvm_install_record_file" > "$rvm_install_record_file.tmp"
1433
+ \grep -v "^$recorded_ruby_name " < "$rvm_install_record_file" \
1434
+ > "$rvm_install_record_file.tmp"
1259
1435
 
1260
1436
  echo "$rvm_install_command" >> "$rvm_install_record_file.tmp"
1261
1437
 
@@ -1266,7 +1442,8 @@ __rvm_record_install() {
1266
1442
  return 0
1267
1443
  }
1268
1444
 
1269
- __rvm_remove_install_record() {
1445
+ __rvm_remove_install_record()
1446
+ {
1270
1447
  local recorded_ruby_name rvm_install_record_file
1271
1448
 
1272
1449
  recorded_ruby_name="$($rvm_path/scripts/tools strings "$1")"
@@ -1277,7 +1454,8 @@ __rvm_remove_install_record() {
1277
1454
 
1278
1455
  \mv "$rvm_install_record_file" "$rvm_install_record_file.tmp"
1279
1456
 
1280
- \grep -v "^$recorded_ruby_name " < "$rvm_install_record_file.tmp" > "$rvm_install_record_file"
1457
+ \grep -v "^$recorded_ruby_name " < "$rvm_install_record_file.tmp" \
1458
+ > "$rvm_install_record_file"
1281
1459
 
1282
1460
  \rm -f "$rvm_install_record_file.tmp"
1283
1461
  fi
@@ -1285,17 +1463,19 @@ __rvm_remove_install_record() {
1285
1463
  return 0
1286
1464
  }
1287
1465
 
1288
- __rvm_recorded_install_command() {
1289
-
1466
+ __rvm_recorded_install_command()
1467
+ {
1290
1468
  local recorded_ruby_name recorded_ruby_match
1291
1469
 
1292
- recorded_ruby_name="$($rvm_path/scripts/tools strings "$1" | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"
1470
+ recorded_ruby_name="$($rvm_path/scripts/tools strings "$1" \
1471
+ | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"
1293
1472
 
1294
1473
  [[ -z "$recorded_ruby_name" ]] && return 1
1295
1474
 
1296
1475
  recorded_ruby_match="^$recorded_ruby_name "
1297
1476
 
1298
- if [[ -s "$rvm_path/config/installs" ]] && \grep -q "$recorded_ruby_match" "$rvm_path/config/installs" ; then
1477
+ if [[ -s "$rvm_path/config/installs" ]] \
1478
+ && \grep -q "$recorded_ruby_match" "$rvm_path/config/installs" ; then
1299
1479
 
1300
1480
  \grep "$recorded_ruby_match" < "$rvm_path/config/installs" | head -n1
1301
1481
 
@@ -1305,8 +1485,8 @@ __rvm_recorded_install_command() {
1305
1485
  return $?
1306
1486
  }
1307
1487
 
1308
- __rvm_environment_identifier() {
1309
-
1488
+ __rvm_environment_identifier()
1489
+ {
1310
1490
  local path string
1311
1491
 
1312
1492
  path="${GEM_HOME:-""}"
@@ -1319,8 +1499,8 @@ __rvm_environment_identifier() {
1319
1499
  return $?
1320
1500
  }
1321
1501
 
1322
- __rvm_expand_ruby_string() {
1323
-
1502
+ __rvm_expand_ruby_string()
1503
+ {
1324
1504
  local string current_ruby
1325
1505
 
1326
1506
  string="$1"
@@ -1352,9 +1532,11 @@ __rvm_expand_ruby_string() {
1352
1532
  ;;
1353
1533
 
1354
1534
  current-ruby|gemsets)
1355
- current_ruby="$(__rvm_environment_identifier | awk -F"${rvm_gemset_separator:-"@"}" '{print $string}')"
1535
+ current_ruby="$(__rvm_environment_identifier \
1536
+ | awk -F"${rvm_gemset_separator:-"@"}" '{print $string}')"
1356
1537
 
1357
- rvm_silence_logging=1 "$rvm_path/scripts/gemsets" list | sed "s/^/$current_ruby${rvm_gemset_separator:-"@"}/"
1538
+ rvm_silence_logging=1 "$rvm_path/scripts/gemsets" list \
1539
+ | sed "s/^/$current_ruby${rvm_gemset_separator:-"@"}/"
1358
1540
  ;;
1359
1541
 
1360
1542
  current)