rvm 1.0.9 → 1.0.10

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.
@@ -3,10 +3,14 @@
3
3
  source "$rvm_path/scripts/base"
4
4
 
5
5
  usage() {
6
- echo "Usage: rvm repair {symlinks,environments,archives,all}" >&2
6
+ echo "Usage: rvm repair {wrappers,symlinks,environments,archives,all}" >&2
7
7
  return 1
8
8
  }
9
9
 
10
+ repair_wrappers() {
11
+ __rvm_regenerate_wrappers
12
+ }
13
+
10
14
  # Removes stale symlinks in $rvm_bin_path, likely
11
15
  # related to wrappers.
12
16
  repair_symlinks() {
@@ -90,6 +94,8 @@ repair_all() {
90
94
 
91
95
  repair_environments
92
96
 
97
+ repair_wrappers
98
+
93
99
  "$rvm_path/scripts/log" "info" \
94
100
  "symlinks, archives and environments have been repaired."
95
101
 
@@ -106,11 +112,12 @@ if [[ -z "$action" ]]; then
106
112
  fi
107
113
 
108
114
  case "$action" in
109
- all) repair_all ;;
110
- symlinks) repair_symlinks ;;
115
+ all) repair_all ;;
116
+ symlinks) repair_symlinks ;;
111
117
  environments) repair_environments ;;
112
- archives) repair_archives;;
113
- *) usage ;;
118
+ archives) repair_archives ;;
119
+ wrappers) repair_wrappers ;;
120
+ *) usage ;;
114
121
  esac
115
122
 
116
123
  exit $?
@@ -4,38 +4,61 @@
4
4
  # http://rvm.beginrescueend.com
5
5
  # http://github.com/wayneeseguin/rvm
6
6
 
7
- if [[ ${rvm_loaded_flag:-0} -eq 0 || ${rvm_reload_flag:-0} -eq 1 ]] ; then
7
+ grep -q '^rvm ()' < <( declare -f ) # Is RVM is a shell function?
8
8
 
9
- unset rvm_reload_flag
9
+ if [[ $? -gt 0 || ${rvm_reload_flag:-0} -eq 1 ]] ; then
10
+
11
+ if [[ ${rvm_ignore_rvmrc:-0} -eq 0 ]]; then
12
+
13
+ for rvmrc in /etc/rvmrc "$HOME/.rvmrc" ; do
10
14
 
11
- if [[ -z "$rvm_ignore_rvmrc" ]]; then
12
- for rvmrc in /etc/rvmrc $HOME/.rvmrc ; do
13
15
  if [[ -f "$rvmrc" ]] ; then
16
+
14
17
  if \grep -q '^\s*rvm .*$' $rvmrc ; then
18
+
15
19
  printf "\nError: $rvmrc is for rvm settings only.\nrvm CLI may NOT be called from within $rvmrc. \nSkipping the loading of $rvmrc"
20
+
16
21
  return 1
22
+
17
23
  else
24
+
18
25
  source "$rvmrc"
26
+
19
27
  fi
28
+
20
29
  fi
30
+
21
31
  done
32
+
22
33
  fi
23
34
 
24
35
  # Set the default sandboxed value.
25
36
  if [[ -z "$rvm_selfcontained" ]]; then
26
- if [[ "root" = "$(whoami)" ]] || [[ -n "$rvm_prefix" && "$rvm_prefix" != "$HOME"/* ]]; then
37
+
38
+ if [[ "root" = "$(whoami)" || -n "$rvm_prefix" && "$rvm_prefix" != "$HOME"/* ]]; then
39
+
27
40
  rvm_selfcontained=0
41
+
28
42
  else
43
+
29
44
  rvm_selfcontained=1
45
+
30
46
  fi
47
+
31
48
  fi
32
49
 
33
50
  if [[ -z "$rvm_prefix" ]] ; then
51
+
34
52
  if [[ "$rvm_selfcontained" = "0" ]] ; then
53
+
35
54
  rvm_prefix="/usr/local/"
55
+
36
56
  else
57
+
37
58
  rvm_prefix="$HOME/."
59
+
38
60
  fi
61
+
39
62
  fi
40
63
 
41
64
  # Fix rvm_prefix changes.
@@ -92,8 +115,6 @@ if [[ ${rvm_loaded_flag:-0} -eq 0 || ${rvm_reload_flag:-0} -eq 1 ]] ; then
92
115
  printf "\n\$rvm_path is not set. rvm cannot load."
93
116
  fi
94
117
 
95
- unset rvm_prefix_needs_trailing_slash rvm_bin_path rvm_man_path rvm_rc_files rvm_gems_path rvm_gems_cache_path rvm_selfcontained rvm_interactive_flag rvm_gems_path rvm_project_rvmrc_default rvm_gemset_separator
96
-
97
- rvm_loaded_flag=1
118
+ unset rvm_prefix_needs_trailing_slash rvm_bin_path rvm_man_path rvm_rc_files rvm_gems_path rvm_gems_cache_path rvm_interactive_flag rvm_gems_path rvm_project_rvmrc_default rvm_gemset_separator
98
119
 
99
120
  fi
@@ -40,6 +40,15 @@ check_rubyopt_conditions() {
40
40
  fi
41
41
  }
42
42
 
43
+ # Regenerates a users wrappers as part of the update.
44
+ regenerate_wrappers() {
45
+ printf "\n"
46
+ if command -v __rvm_regenerate_wrappers >/dev/null; then
47
+ __rvm_regenerate_wrappers
48
+ fi
49
+ printf "\n"
50
+ }
51
+
43
52
  andand_return_instructions() {
44
53
  printf "
45
54
  This means that if you see something like:
@@ -493,6 +502,15 @@ for file in rvm rvmsudo rvm-shell rvm-auto-ruby ; do
493
502
 
494
503
  done
495
504
 
505
+ # Cleanup any .swp files that might have appeared.
506
+ files=($( find "$rvm_path/" -mindepth 1 -maxdepth 2 -iname '*.swp' -type f ))
507
+
508
+ for file in "${files[@]}" ; do
509
+
510
+ [[ -f "$file" ]] && rm -f "$file"
511
+
512
+ done
513
+
496
514
  printf "\n Copying manpages into place."
497
515
 
498
516
  files=($(builtin cd "$install_source_path/man" ; find . -maxdepth 1 -mindepth 1 -type f -print))
@@ -514,6 +532,8 @@ if [[ ${upgrade_flag:-0} -eq 1 ]] ; then
514
532
  upgrade_notes
515
533
 
516
534
  check_rubyopt_conditions
535
+
536
+ regenerate_wrappers
517
537
 
518
538
  printf "\nUpgrade of RVM in $rvm_path/ is complete.\n\n"
519
539
 
@@ -18,6 +18,10 @@ __rvm_select() {
18
18
 
19
19
  rvm_archive_extension="tar.gz"
20
20
 
21
+ if [[ -z "${rvm_ruby_interpreter:-""}" ]] ; then
22
+ rvm_ruby_interpreter="${rvm_ruby_string//-*/}"
23
+ fi
24
+
21
25
  case "$rvm_ruby_interpreter" in
22
26
  macruby)
23
27
  if [[ "Darwin" = "$(uname)" ]] ; then
@@ -168,7 +172,7 @@ __rvm_select() {
168
172
 
169
173
  ruby)
170
174
  if [[ -z "${rvm_ruby_version:-""}" && ${rvm_head_flag:-0} -eq 0 ]]; then
171
- "$rvm_path/scripts/log" "fail" "Unknown ruby version: $rvm_ruby_version"
175
+ "$rvm_path/scripts/log" "fail" "Ruby version was not specified!"
172
176
 
173
177
  else
174
178
  rvm_ruby_repo_url="${rvm_ruby_repo_url:-"$(__rvm_db "ruby_repo_url")"}"
@@ -276,20 +280,26 @@ __rvm_use() {
276
280
  fi
277
281
 
278
282
  # Check binaries, remove under the condition they're symlinks.
279
- if [[ "$rvm_selfcontained" = "0" ]] ; then
283
+ if [[ ${rvm_selfcontained:-1} -eq 0 ]] ; then
280
284
 
281
285
  for binary in ruby gem irb ri rdoc rake erb testrb ; do
282
286
 
283
287
  full_binary_path="${rvm_bin_path:-"$rvm_path/bin"}/$binary"
284
288
 
285
289
  [[ -L "$full_binary_path" ]] && \rm -f "$full_binary_path"
290
+
286
291
  done
292
+
287
293
  fi
288
294
 
289
295
  if [[ ${rvm_verbose_flag:-0} -gt 0 ]] ; then
290
296
  "$rvm_path/scripts/log" "info" "Now using system ruby."
291
297
  fi
292
298
 
299
+ __rvm_remove_rvm_from_path
300
+
301
+ new_path="$PATH:${rvm_bin_path:-"$rvm_path/bin"}"
302
+
293
303
  export rvm_ruby_string="system"
294
304
 
295
305
  else
@@ -338,56 +348,59 @@ __rvm_use() {
338
348
  builtin hash -r
339
349
  fi
340
350
 
341
- if [[ ${rvm_rvmrc_flag:-0} -eq 1 ]] ; then __rvm_set_rvmrc ; fi
351
+ if [[ "$rvm_ruby_string" != "system" ]] ; then
342
352
 
343
- local environment_id="$(__rvm_environment_identifier)"
353
+ if [[ ${rvm_rvmrc_flag:-0} -eq 1 ]] ; then __rvm_set_rvmrc ; fi
344
354
 
345
- if [[ ${rvm_default_flag:-0} -eq 1 && "default" != "${rvm_ruby_interpreter:-""}" ]] ; then
355
+ local environment_id="$(__rvm_environment_identifier)"
346
356
 
347
- if [[ ${rvm_selfcontained:-""} -eq 0 ]] ; then
348
- # Sets up the default wrappers.
349
- "$rvm_path/scripts/wrapper" "$rvm_ruby_string" --no-prefix
350
- else
351
- "$rvm_path/scripts/wrapper" "$rvm_ruby_string" "default"
352
- fi
357
+ if [[ ${rvm_default_flag:-0} -eq 1 && "default" != "${rvm_ruby_interpreter:-""}" ]] ; then
353
358
 
354
- if [[ "system" = "$rvm_ruby_interpreter" ]] ; then
355
- "$rvm_path/scripts/alias" delete default &> /dev/null
356
- \find "${rvm_bin_path:-"$rvm_path/bin"}" -name 'default_*' -maxdepth 0 -delete
357
- \rm -f "$rvm_path/config/default"
358
- \rm -f "$rvm_path/environments/default"
359
- \rm -rf "$rvm_path/wrappers/default"
359
+ if [[ ${rvm_selfcontained:-""} -eq 0 ]] ; then
360
+ # Sets up the default wrappers.
361
+ "$rvm_path/scripts/wrapper" "$rvm_ruby_string" --no-prefix
362
+ else
363
+ "$rvm_path/scripts/wrapper" "$rvm_ruby_string" "default"
364
+ fi
360
365
 
361
- else
362
- RUBY_VERSION="$("$rvm_ruby_home/bin/ruby" -v | sed 's#^\(.*\) (.*$#\1#')"
363
- export GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION
364
- "$rvm_path/scripts/alias" delete default &> /dev/null
365
- "$rvm_path/scripts/alias" create default "$environment_id" >& /dev/null
366
- \ln -nfs "$rvm_path/environments/$environment_id" "$rvm_path/environments/default"
367
- \ln -nfs "$rvm_path/wrappers/$environment_id" "$rvm_path/wrappers/default"
366
+ if [[ "system" = "$rvm_ruby_interpreter" ]] ; then
367
+ "$rvm_path/scripts/alias" delete default &> /dev/null
368
+ \find "${rvm_bin_path:-"$rvm_path/bin"}" -name 'default_*' -maxdepth 0 -delete
369
+ \rm -f "$rvm_path/config/default"
370
+ \rm -f "$rvm_path/environments/default"
371
+ \rm -rf "$rvm_path/wrappers/default"
372
+
373
+ else
374
+ RUBY_VERSION="$("$rvm_ruby_home/bin/ruby" -v | sed 's#^\(.*\) (.*$#\1#')"
375
+ export GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION
376
+ "$rvm_path/scripts/alias" delete default &> /dev/null
377
+ "$rvm_path/scripts/alias" create default "$environment_id" >& /dev/null
378
+ \ln -nfs "$rvm_path/environments/$environment_id" "$rvm_path/environments/default"
379
+ \ln -nfs "$rvm_path/wrappers/$environment_id" "$rvm_path/wrappers/default"
380
+ fi
368
381
  fi
369
- fi
370
382
 
371
- rvm_default_flag=0
383
+ rvm_default_flag=0
372
384
 
373
- if [[ -n "${rvm_wrapper_name:-""}" ]] ; then
374
- "$rvm_path/scripts/wrapper" "$environment_id" "$rvm_wrapper_name" > /dev/null 2>&1
375
- rvm_wrapper_name=""
376
- fi
385
+ if [[ -n "${rvm_wrapper_name:-""}" ]] ; then
386
+ "$rvm_path/scripts/wrapper" "$environment_id" "$rvm_wrapper_name" > /dev/null 2>&1
387
+ rvm_wrapper_name=""
388
+ fi
377
389
 
378
- if [[ -n "${rvm_ruby_alias:-""}" ]]; then
379
- "$rvm_path/scripts/log" "info" "Attempting to alias $environment_id to $rvm_ruby_alias"
380
- "$rvm_path/scripts/alias" delete "$rvm_ruby_alias" > /dev/null 2>&1
381
- rvm_alias_expanded=1 "$rvm_path/scripts/alias" create "$rvm_ruby_alias" "$environment_id" > /dev/null 2>&1
382
- ruby_alias="" ; rvm_ruby_alias=""
383
- fi
390
+ if [[ -n "${rvm_ruby_alias:-""}" ]]; then
391
+ "$rvm_path/scripts/log" "info" "Attempting to alias $environment_id to $rvm_ruby_alias"
392
+ "$rvm_path/scripts/alias" delete "$rvm_ruby_alias" > /dev/null 2>&1
393
+ rvm_alias_expanded=1 "$rvm_path/scripts/alias" create "$rvm_ruby_alias" "$environment_id" > /dev/null 2>&1
394
+ ruby_alias="" ; rvm_ruby_alias=""
395
+ fi
384
396
 
385
- if [[ "maglev" = "${rvm_ruby_interpreter:-""}" ]] ; then
386
- export MAGLEV_HOME="$rvm_ruby_home"
387
- export GEMSTONE_GLOBAL_DIR=$MAGLEV_HOME
388
- if [[ -x "$MAGLEV_HOME/gemstone/bin/gslist" ]] ; then
389
- "$MAGLEV_HOME/gemstone/bin/gslist" -clv > /dev/null 2>&1 ; result=$?
390
- if [[ $result -eq 1 ]] ; then "$rvm_ruby_home/bin/maglev" start ; fi
397
+ if [[ "maglev" = "${rvm_ruby_interpreter:-""}" ]] ; then
398
+ export MAGLEV_HOME="$rvm_ruby_home"
399
+ export GEMSTONE_GLOBAL_DIR=$MAGLEV_HOME
400
+ if [[ -x "$MAGLEV_HOME/gemstone/bin/gslist" ]] ; then
401
+ "$MAGLEV_HOME/gemstone/bin/gslist" -clv > /dev/null 2>&1 ; result=$?
402
+ if [[ $result -eq 1 ]] ; then "$rvm_ruby_home/bin/maglev" start ; fi
403
+ fi
391
404
  fi
392
405
  fi
393
406
 
@@ -422,20 +435,27 @@ __rvm_ruby_string() {
422
435
  fi
423
436
 
424
437
  # Alias'd rubies
425
- if [[ ${rvm_expanding_aliases:-0} -eq 0 && -n ${rvm_ruby_string:-""} ]]; then
438
+ if [[ ${rvm_expanding_aliases:-0} -eq 0 && -n ${rvm_ruby_string:-""} && $rvm_ruby_string != "system" ]]; then
439
+
426
440
  if expanded_alias_name="$("$rvm_path/scripts/alias" show "$rvm_ruby_string" 2>/dev/null)" && [[ -n "$expanded_alias_name" ]] ; then
441
+
427
442
  rvm_ruby_string="$expanded_alias_name"
428
443
 
429
444
  elif [[ "$rvm_ruby_string" = default ]]; then
445
+
430
446
  # Default is not a known value. Instead, we need to therefore set it to system.
431
447
  rvm_ruby_string="system"
448
+
432
449
  fi
450
+
433
451
  fi
434
452
 
435
453
  ruby_string=${rvm_ruby_string/${rvm_gemset_separator:-"@"}*/}
436
454
 
437
455
  __rvm_unset_ruby_variables
438
456
 
457
+ rvm_ruby_string=${rvm_ruby_string:-""}
458
+
439
459
  strings=($(echo ${ruby_string//-/ }))
440
460
 
441
461
  if [[ ${#strings[@]} -eq 0 ]] ; then
@@ -5,6 +5,7 @@ source "$rvm_path/scripts/base"
5
5
  __rvm_attempt_single_exec() {
6
6
  # Return if we have multiple rubies. or we're not running exec.
7
7
  if [[ "$action" = "exec" && ${#rvm_ruby_strings[@]} -lt 2 ]]; then
8
+
8
9
  __rvm_become "$rvm_ruby_strings"
9
10
 
10
11
  eval "exec ${args[@]}"
@@ -15,14 +16,16 @@ __rvm_attempt_single_exec() {
15
16
 
16
17
  # Perform an action using one of a selected ruby's specified binaries.
17
18
  __rvm_ruby_do() {
19
+
18
20
  # Return on invalid rubies.
19
21
  __rvm_become "$current_set_ruby" || return 1
20
22
 
21
23
  if [[ "$action" = "exec" ]]; then
22
24
  # Exec is a special case.
23
- rvm_command="$args"
25
+ rvm_command="${args[@]}"
24
26
 
25
27
  else
28
+
26
29
  binary="$(echo $action | sed 's#do$##')"
27
30
 
28
31
  if [[ -x "$rvm_ruby_home/bin/$binary" ]] ; then
@@ -66,22 +69,22 @@ __rvm_ruby_do() {
66
69
  # TODO: the else case below should be run if $args =~ /\.rb$/
67
70
  if [[ "ruby" = "$(basename $binary)" && "$rvm_benchmark_flag" -ne 1 ]] ; then
68
71
 
69
- if "$rvm_path/scripts/match" "$args" "\.rb$" ; then
72
+ if "$rvm_path/scripts/match" "${args[@]}" "\.rb$" ; then
70
73
 
71
74
  if [[ -z "$prefix" ]] ; then prefix="-S" ; fi
72
75
 
73
- if ! "$rvm_path/scripts/match" "$args" "$prefix" ; then
76
+ if ! "$rvm_path/scripts/match" "${args[@]}" "$prefix" ; then
74
77
 
75
- args="$prefix $args"
78
+ args=($prefix ${args[@]})
76
79
 
77
80
  fi
78
81
  fi
79
82
 
80
- rvm_command="$(printf "$binary $rvm_ruby_mode $rvm_ruby_require -I$load_path $args")"
83
+ rvm_command="$binary $rvm_ruby_mode $rvm_ruby_require -I$load_path ${args[@]}"
81
84
 
82
85
  else
83
86
 
84
- rvm_command="$(printf "$binary $rvm_ruby_mode $args")"
87
+ rvm_command="$binary $rvm_ruby_mode ${args[@]}"
85
88
 
86
89
  fi
87
90
 
@@ -89,11 +92,15 @@ __rvm_ruby_do() {
89
92
 
90
93
  if [[ -n "$rvm_json_flag" || -n "$rvm_yaml_flag" || -n "$rvm_summary_flag" ]] ; then
91
94
 
92
- mkdir -p ./log/$rvm_ruby_string/
95
+ if [[ ! -d "./log/$rvm_ruby_string/" ]] ; then
96
+ mkdir -p "./log/$rvm_ruby_string/"
97
+ fi
93
98
 
94
99
  touch ./log/$rvm_ruby_string/$action.log ./log/$rvm_ruby_string/$action.error.log
95
100
 
96
- eval "$rvm_command" >> ./log/$rvm_ruby_string/$action.log 2>> ./log/$rvm_ruby_string/$action.error.log
101
+ eval "$rvm_command" \
102
+ >> ./log/$rvm_ruby_string/$action.log \
103
+ 2>> ./log/$rvm_ruby_string/$action.error.log
97
104
 
98
105
  else
99
106
  if [[ ${rvm_verbose_flag:-0} -gt 0 ]] ; then
@@ -106,7 +113,8 @@ __rvm_ruby_do() {
106
113
 
107
114
  fi
108
115
 
109
- "$rvm_path/scripts/log" "info" "$current_env: $(ruby -v $rvm_ruby_mode | \tr "\n" ' ')\n"
116
+ "$rvm_path/scripts/log" "info" \
117
+ "$current_env: $(ruby -v $rvm_ruby_mode | \tr "\n" ' ')\n"
110
118
 
111
119
  unset current_env
112
120
  fi
@@ -115,6 +123,7 @@ __rvm_ruby_do() {
115
123
  result=$?
116
124
 
117
125
  string=$(basename $rvm_ruby_gem_home)
126
+
118
127
  if [[ $result -eq 0 ]]; then
119
128
 
120
129
  eval "successes=(${successes[*]} $string)"
@@ -164,6 +173,7 @@ __rvm_summary() {
164
173
 
165
174
  # Output the summary in a yaml format.
166
175
  __rvm_yaml() {
176
+
167
177
  export successes errors statuses
168
178
 
169
179
  yaml="totals:\n rubies: ${#rubies[*]}\n successes: ${#successes[*]}\n errors: ${#errors[*]}\nsuccesses:"
@@ -201,6 +211,9 @@ __rvm_yaml() {
201
211
 
202
212
  # Output the summary in a json format.
203
213
  __rvm_json() {
214
+
215
+ local index array_start
216
+
204
217
  json="{
205
218
  \"totals\": { \"rubies\": ${#rubies[*]}, \"successes\": ${#successes[*]}, \"errors\": ${#errors[*]} },
206
219
  \"successful\": [$(echo \"${successes[*]}\" | sed 's# #", "#g' | sed 's#\"\"##')],
@@ -223,11 +236,13 @@ __rvm_json() {
223
236
  if (( $index + 1 < $total + $array_start )) ; then json="$json, " ; fi
224
237
 
225
238
  done
226
- unset index array_start
227
239
 
228
240
  json="$json\n }\n}"
229
241
 
230
- mkdir -p log
242
+ if [[ ! -d log ]] ; then
243
+ mkdir -p log
244
+ fi
245
+
231
246
  printf "$json" | tee -a log/summary.json
232
247
 
233
248
  return ${#errors[*]}
@@ -239,8 +254,9 @@ __rvm_json() {
239
254
  rubies=() ; successes=() ; errors=() ; statuses=()
240
255
 
241
256
  args=($*)
242
- action="${args[0]}"
243
- args=${args[@]:1}
257
+ action="${args[$__array_start]}"
258
+ args[$__array_start]=""
259
+ args=(${args[@]})
244
260
 
245
261
  if [[ -z "$action" ]] ; then
246
262