rvm 1.0.0 → 1.0.1

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.
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+
3
+ if [[ -z "$rvm_leave_gem_alone" ]]; then
4
+ gem() {
5
+ command gem "$@"
6
+ local gem_result="$?"
7
+ hash -r
8
+ return $gem_result
9
+ }
10
+ fi
@@ -11,7 +11,7 @@ usage() {
11
11
  # related to wrappers.
12
12
  repair_symlinks() {
13
13
  __rvm_pushpop "$rvm_bin_path"
14
- for executable_name in $(\find . -type l); do
14
+ for executable_name in $(\find \. -type l); do
15
15
  [[ -e "$executable_name" || "$(readlink "$executable_name")" != "$rvm_wrappers_path/"* ]] && continue
16
16
  if [[ -f "$executable_name" ]] ; then
17
17
  $rvm_scripts_path/log "info" "Removing stale symlink from $(basename "$executable_name")"
@@ -49,7 +49,7 @@ rubygems_setup() {
49
49
  $rvm_scripts_path/log "error" "There has been an error while trying to fetch the source. Aborting the installation." ; __rvm_pushpop ; return $result
50
50
  fi
51
51
  \mkdir -p "$rvm_src_path/$rvm_gem_package_name"
52
- __rvm_run "rubygems.extract" "cat $rvm_archives_path/$rvm_gem_package_name.tgz | gunzip | tar xf - -C $rvm_src_path" "Extracting $rvm_gem_package_name ..."
52
+ __rvm_run "rubygems.extract" "gunzip < $rvm_archives_path/$rvm_gem_package_name.tgz | tar xf - -C $rvm_src_path" "Extracting $rvm_gem_package_name ..."
53
53
  fi
54
54
 
55
55
  builtin cd "$rvm_src_path/$rvm_gem_package_name"
@@ -61,16 +61,23 @@ if [[ "$rvm_loaded_flag" != "1" ]] || [[ "$rvm_reload_flag" = "1" ]] ; then
61
61
  source "$rvm_scripts_path/cli"
62
62
  source "$rvm_scripts_path/manpages"
63
63
  source "$rvm_scripts_path/cd"
64
+ source "$rvm_scripts_path/override_gem"
64
65
 
65
66
  rvm_loaded_flag=1
66
67
 
67
- rvm_version="$(cat "${rvm_path}/lib/VERSION.yml" | tail -n 3 | sed 's/^.*: //g' | \tr "\n" '.' | sed 's/\.$//')" ; export rvm_version
68
+ rvm_version="$(tail -n 3 < "${rvm_path}/lib/VERSION.yml" | sed -e 's/^.*: //g' | \tr "\n" '.' | sed -e 's/\.$//')" ; export rvm_version
68
69
 
69
70
  alias rvm-restart="source '${rvm_path}/scripts/rvm'"
70
71
 
71
72
  if ! command -v ruby >/dev/null 2>&1 || command -v ruby | \grep -v rvm >/dev/null ; then
72
- [[ -s "$rvm_environments_path/default" ]] && source "$rvm_environments_path/default"
73
+ if [[ -s "$rvm_environments_path/default" ]] ; then
74
+ source "$rvm_environments_path/default"
75
+ fi
73
76
  fi
77
+
78
+ # Makes sure rvm_bin_path is in PATH atleast once.
79
+ __rvm_conditionally_add_bin_path
80
+
74
81
  else
75
82
  printf "\n\$rvm_path is not set. rvm cannot load."
76
83
  fi
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
+ #set -u # Error on uninitialized variables.
4
+
3
5
  if [[ -z "$rvm_selfcontained" ]]; then
4
6
  if [[ "root" = "$(whoami)" ]] || [[ -n "$rvm_prefix" && "$rvm_prefix" != "$HOME"/* ]]; then
5
7
  export rvm_selfcontained=0
@@ -15,6 +17,8 @@ if [[ -d "$install_source_path/scripts" ]] && [[ -s "$install_source_path/script
15
17
  builtin cd "$install_source_path"
16
18
  fi
17
19
 
20
+ sleep=0.010
21
+
18
22
  source scripts/version
19
23
  source scripts/utility
20
24
 
@@ -44,7 +48,7 @@ spinner() {
44
48
  index=$((($spinner_counter % 8)))
45
49
  printf "\r${array[$index]}"
46
50
  let "spinner_counter=spinner_counter+1"
47
- command -v perl > /dev/null 2>&1 && perl -e 'sleep 0.5'
51
+ sleep $sleep
48
52
  }
49
53
 
50
54
  if echo "$*" | \grep -q 'trace' ; then echo "$*" ; env | \grep '^rvm_' ; set -x ; fi
@@ -54,7 +58,7 @@ while [[ $# -gt 0 ]] ; do
54
58
  case "$token" in
55
59
  --auto) rvm_auto_flag=1 ;;
56
60
  --prefix) rvm_prefix="$1" ; shift ;;
57
- --version) rvm_path="$(pwd)" ; __rvm_version ; unset rvm_path ; exit ;;
61
+ --version) rvm_path="$PWD" ; __rvm_version ; unset rvm_path ; exit ;;
58
62
  --help|*) usage ;;
59
63
  esac
60
64
  done
@@ -89,7 +93,7 @@ __rvm_initialize
89
93
  #
90
94
  item="$(tput setaf 2)* $(tput sgr0)"
91
95
  question="\n$(tput setaf 2)<?>$(tput sgr0)"
92
- cwd=$(pwd)
96
+ cwd=$PWD
93
97
  source_path="${source_path:-$cwd}"
94
98
  rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
95
99
  rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
@@ -161,7 +165,7 @@ done
161
165
  #
162
166
  # Cleanse and purge...
163
167
  for file in rvm-prompt rvm rvmsudo rvm-shell rvm-auto-ruby ; do
164
- spinner && perl -e 'sleep 0.2'
168
+ spinner && sleep $sleep
165
169
  \rm -f "$rvm_bin_path/$file"
166
170
  \cp -f "$source_path/binscripts/$file" $rvm_bin_path/
167
171
  done
@@ -197,7 +201,7 @@ fi
197
201
  spinner
198
202
  if [[ -d gemsets/ ]] ; then
199
203
  \mkdir -p "$rvm_gemsets_path"
200
- for gemset_file in $(cd gemsets ; find . -iname '*.gems' | sed 's/^\.\///') ; do
204
+ for gemset_file in $(cd gemsets ; find \. -iname '*.gems' | sed 's/^\.\///') ; do
201
205
  destination="$rvm_gemsets_path/$gemset_file"
202
206
  destination_path="$(dirname "$destination")"
203
207
  if [[ ! -s "$destination" ]] ; then
@@ -210,7 +214,7 @@ fi
210
214
  spinner
211
215
  if [[ -d patchsets/ ]] ; then
212
216
  \mkdir -p "$rvm_patchsets_path"
213
- for patchset_file in $(cd patchsets ; find . -iname '*' | sed 's/^\.\///') ; do
217
+ for patchset_file in $(cd patchsets ; find \. -iname '*' | sed 's/^\.\///') ; do
214
218
  destination="$rvm_patchsets_path/$patchset_file"
215
219
  destination_path="$(dirname "$destination")"
216
220
  if [[ ! -s "$destination" ]] ; then
@@ -306,7 +310,7 @@ printf "\nThank you for using rvm. I hope that it makes your work easier and mor
306
310
  printf "\nIf you have any questions, issues and/or ideas for improvement please hop in #rvm on irc.freenode.net and let me know."
307
311
  printf "\nMy irc nickname is 'wayneeseguin' and I hang out from ~09:00-17:00EST and again from ~21:00EST-~00:00EST."
308
312
  printf "\nIf I do not respond right away, please hang around after asking your question, I will respond as soon as I am back."
309
- printf "\nBe sure to get head often as rvm development happens fast, you can do this by typing 'rvm update --head'."
313
+ printf "\nBe sure to get head often as rvm development happens fast, you can do this by running 'rvm update --head'."
310
314
  printf "\n w$(tput setaf 2)⦿‿⦿$(tput sgr0)t!"
311
315
  printf "\n ~ Wayne\n"
312
316
 
@@ -229,8 +229,8 @@ __rvm_use() {
229
229
  if [[ "system" = "$rvm_ruby_interpreter" ]] ; then
230
230
 
231
231
  unset GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION IRBRC
232
- new_path="$(echo $PATH | \tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -)"
233
- new_path="$rvm_bin_path:$new_path"
232
+
233
+ new_path="$rvm_bin_path:$(__rvm_remove_rvm_from_path ; printf $PATH)"
234
234
  if [[ -s $rvm_config_path/system ]] ; then
235
235
  \grep "MY_RUBY_HOME='$rvm_rubies_path" "$rvm_config_path/system" > /dev/null
236
236
  if [[ $? -eq 0 ]] ; then
@@ -283,14 +283,17 @@ __rvm_use() {
283
283
  $rvm_scripts_path/log "info" "Using $(basename $GEM_HOME | \tr '-' ' ' | sed 's/'${rvm_gemset_separator}'/ with gemset /')"
284
284
  fi
285
285
 
286
- new_path="$(echo $PATH | \tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -)"
287
- new_path="$GEM_HOME/bin:$rvm_ruby_global_gems_path/bin:$MY_RUBY_HOME/bin:$rvm_bin_path:$new_path"
286
+ new_path="$GEM_HOME/bin:$rvm_ruby_global_gems_path/bin:$MY_RUBY_HOME/bin:$rvm_bin_path:$(__rvm_remove_rvm_from_path ; printf $PATH)"
288
287
  fi
289
288
 
290
289
  # Export ruby string and gem set me for extrenal scripts to take advantage of them.
291
290
  if [[ -n "$rvm_ruby_string" ]] ; then export rvm_ruby_string ; fi
292
291
  if [[ -n "$rvm_gemset_name" ]] ; then export rvm_gemset_name ; fi
293
- if [[ -n "$new_path" ]] ; then export PATH="$new_path" ; unset new_path ; fi
292
+ if [[ -n "$new_path" ]]; then
293
+ export PATH="$new_path"
294
+ unset new_path
295
+ builtin hash -r
296
+ fi
294
297
  if [[ -n "$rvm_rvmrc_flag" ]] ; then __rvm_set_rvmrc ; fi
295
298
 
296
299
  environment_id="$(__rvm_environment_identifier)"
@@ -340,9 +343,6 @@ __rvm_use() {
340
343
  if [[ $result -eq 1 ]] ; then $rvm_ruby_home/bin/maglev start ; fi
341
344
  fi
342
345
  fi
343
-
344
- # Rehash executable locations, e.g. to force the shell to recognize new items in the path.
345
- builtin hash -r
346
346
  rvm_hook="after_use" ; source $rvm_scripts_path/hook
347
347
  }
348
348
 
@@ -34,7 +34,7 @@ snapshot_save() {
34
34
  \cp "$rvm_config_path/user" "$snapshot_temp_path/"
35
35
 
36
36
  $rvm_scripts_path/log "info" "Backing up your installed packages"
37
- cat "$rvm_config_path/packages" | sed -e 's/-//' -e 's/^lib//' | awk -F= '{print $1}' | sort | uniq > "$snapshot_temp_path/packages"
37
+ sed -e 's/-//' -e 's/^lib//' < "$rvm_config_path/packages" | awk -F= '{print $1}' | sort | uniq > "$snapshot_temp_path/packages"
38
38
 
39
39
  $rvm_scripts_path/log "info" "Backing up all of your gemsets"
40
40
  \mkdir -p "$snapshot_temp_path/gems"
@@ -63,8 +63,8 @@ snapshot_save() {
63
63
  comm -2 -3 "$snapshot_ruby_name_file" "$snapshot_alias_name_file" > "$snapshot_installable_file"
64
64
  \rm -rf "$snapshot_ruby_name_file" "$snapshot_alias_name_file"
65
65
 
66
- local snapshot_primary_ruby="$(cat "$snapshot_installable_file" | \grep '^\(ree\|ruby-1.8.7\)' | \grep -v '-head$' | sort -r | head -n1)"
67
- local snapshot_ruby_order="$snapshot_primary_ruby $(cat "$snapshot_installable_file" | \grep -v "$snapshot_primary_ruby")"
66
+ local snapshot_primary_ruby="$(\grep '^\(ree\|ruby-1.8.7\)' < "$snapshot_installable_file" | \grep -v '-head$' | sort -r | head -n1)"
67
+ local snapshot_ruby_order="$snapshot_primary_ruby $(\grep -v "$snapshot_primary_ruby" < "$snapshot_installable_file")"
68
68
  for snapshot_ruby_name in $snapshot_ruby_order ; do
69
69
  snapshot_install_command="$(__rvm_recorded_install_command "$snapshot_ruby_name")"
70
70
  if [[ -n "$snapshot_install_command" ]]; then
@@ -18,9 +18,14 @@ tools_path_identifier() {
18
18
  return 1
19
19
  fi
20
20
  # Change to the directory. Do in subshell to keep the env correct.
21
- (source $rvm_scripts_path/rvm
22
- cd "$1" >/dev/null 2>&1
23
- __rvm_environment_identifier)
21
+ (
22
+ source "$rvm_scripts_path/rvm"
23
+ builtin cd "$1"
24
+ rvm_promptless=1 __rvm_project_rvmrc
25
+ rvmrc_result="$?"
26
+ __rvm_environment_identifier
27
+ exit $rvmrc_result
28
+ )
24
29
  }
25
30
 
26
31
  tools_strings() {
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
+ #set -u # Error on uninitialized variables.
4
+
3
5
  if [[ -z "$rvm_selfcontained" ]]; then
4
6
  if [[ "root" = "$(whoami)" ]] || [[ -n "$rvm_prefix" && "$rvm_prefix" != "$HOME"/* ]]; then
5
7
  export rvm_selfcontained=0
@@ -15,6 +17,8 @@ if [[ -d "$install_source_path/scripts" ]] && [[ -s "$install_source_path/script
15
17
  builtin cd "$install_source_path"
16
18
  fi
17
19
 
20
+ sleep=0.010
21
+
18
22
  source scripts/version
19
23
  source scripts/utility
20
24
 
@@ -44,7 +48,7 @@ spinner() {
44
48
  index=$((($spinner_counter % 8)))
45
49
  printf "\r${array[$index]}"
46
50
  let "spinner_counter=spinner_counter+1"
47
- command -v perl > /dev/null 2>&1 && perl -e 'sleep 0.5'
51
+ sleep $sleep
48
52
  }
49
53
 
50
54
  if echo "$*" | \grep -q 'trace' ; then echo "$*" ; env | \grep '^rvm_' ; set -x ; fi
@@ -54,7 +58,7 @@ while [[ $# -gt 0 ]] ; do
54
58
  case "$token" in
55
59
  --auto) rvm_auto_flag=1 ;;
56
60
  --prefix) rvm_prefix="$1" ; shift ;;
57
- --version) rvm_path="$(pwd)" ; __rvm_version ; unset rvm_path ; exit ;;
61
+ --version) rvm_path="$PWD" ; __rvm_version ; unset rvm_path ; exit ;;
58
62
  --help|*) usage ;;
59
63
  esac
60
64
  done
@@ -89,7 +93,7 @@ __rvm_initialize
89
93
  #
90
94
  item="$(tput setaf 2)* $(tput sgr0)"
91
95
  question="\n$(tput setaf 2)<?>$(tput sgr0)"
92
- cwd=$(pwd)
96
+ cwd=$PWD
93
97
  source_path="${source_path:-$cwd}"
94
98
  rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
95
99
  rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
@@ -161,7 +165,7 @@ done
161
165
  #
162
166
  # Cleanse and purge...
163
167
  for file in rvm-prompt rvm rvmsudo rvm-shell rvm-auto-ruby ; do
164
- spinner && perl -e 'sleep 0.2'
168
+ spinner && sleep $sleep
165
169
  \rm -f "$rvm_bin_path/$file"
166
170
  \cp -f "$source_path/binscripts/$file" $rvm_bin_path/
167
171
  done
@@ -197,7 +201,7 @@ fi
197
201
  spinner
198
202
  if [[ -d gemsets/ ]] ; then
199
203
  \mkdir -p "$rvm_gemsets_path"
200
- for gemset_file in $(cd gemsets ; find . -iname '*.gems' | sed 's/^\.\///') ; do
204
+ for gemset_file in $(cd gemsets ; find \. -iname '*.gems' | sed 's/^\.\///') ; do
201
205
  destination="$rvm_gemsets_path/$gemset_file"
202
206
  destination_path="$(dirname "$destination")"
203
207
  if [[ ! -s "$destination" ]] ; then
@@ -210,7 +214,7 @@ fi
210
214
  spinner
211
215
  if [[ -d patchsets/ ]] ; then
212
216
  \mkdir -p "$rvm_patchsets_path"
213
- for patchset_file in $(cd patchsets ; find . -iname '*' | sed 's/^\.\///') ; do
217
+ for patchset_file in $(cd patchsets ; find \. -iname '*' | sed 's/^\.\///') ; do
214
218
  destination="$rvm_patchsets_path/$patchset_file"
215
219
  destination_path="$(dirname "$destination")"
216
220
  if [[ ! -s "$destination" ]] ; then
@@ -306,7 +310,7 @@ printf "\nThank you for using rvm. I hope that it makes your work easier and mor
306
310
  printf "\nIf you have any questions, issues and/or ideas for improvement please hop in #rvm on irc.freenode.net and let me know."
307
311
  printf "\nMy irc nickname is 'wayneeseguin' and I hang out from ~09:00-17:00EST and again from ~21:00EST-~00:00EST."
308
312
  printf "\nIf I do not respond right away, please hang around after asking your question, I will respond as soon as I am back."
309
- printf "\nBe sure to get head often as rvm development happens fast, you can do this by typing 'rvm update --head'."
313
+ printf "\nBe sure to get head often as rvm development happens fast, you can do this by running 'rvm update --head'."
310
314
  printf "\n w$(tput setaf 2)⦿‿⦿$(tput sgr0)t!"
311
315
  printf "\n ~ Wayne\n"
312
316
 
@@ -156,12 +156,14 @@ __rvm_set_path_variable() {
156
156
  __rvm_clean_path() {
157
157
  PATH=$(echo $PATH | \tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' | \tr -s '\n' ':' | sed 's#:$##')
158
158
  export PATH
159
+ builtin hash -r
159
160
  }
160
161
 
161
162
  # Clean all rvm items out of the current working path.
162
163
  __rvm_remove_rvm_from_path() {
163
- PATH=$(echo $PATH | \tr -s ':' '\n' | \grep -v "\.rvm" | \tr -s '\n' ':' | sed 's#:$##')
164
+ PATH=$(echo $PATH | \tr -s ':' '\n' | \grep -v "rvm" | \tr -s '\n' ':' | sed 's#:$##')
164
165
  export PATH
166
+ builtin hash -r
165
167
  }
166
168
 
167
169
  # Run a specified command and log it.
@@ -283,7 +285,7 @@ __rvm_cleanup_temp_on_exit() {
283
285
  }
284
286
 
285
287
  __rvm_set_rvmrc() {
286
- if [[ "$HOME" != "$(pwd)" ]] ; then
288
+ if [[ "$HOME" != "$PWD" ]] ; then
287
289
  if [[ "$rvm_verbose_flag" -eq 1 ]] ; then flags="use " ; fi
288
290
 
289
291
  if [[ -s .rvmrc ]] ; then
@@ -292,7 +294,7 @@ __rvm_set_rvmrc() {
292
294
  fi
293
295
 
294
296
  local identifier=$(__rvm_environment_identifier)
295
- printf "if [[ -n \"\$rvm_environments_path\" && -s \"\$rvm_environments_path/$identifier\" ]] ; then\n . \"\$rvm_environments_path/$identifier\"" > .rvmrc
297
+ printf "if [[ -n \"\$rvm_environments_path\" && -s \"\$rvm_environments_path/$identifier\" ]] ; then\n \\. \"\$rvm_environments_path/$identifier\"" > .rvmrc
296
298
  printf "\nelse\n rvm --create $flags \"$identifier\"\nfi" >> .rvmrc
297
299
 
298
300
  unset flags
@@ -354,11 +356,21 @@ __rvm_bin_script() {
354
356
  $rvm_scripts_path/wrapper "$rvm_ruby_string"
355
357
  }
356
358
 
359
+ # Add bin path if not present
360
+ __rvm_conditionally_add_bin_path() {
361
+ if echo "$PATH" | \tr ':' ' ' | \grep -vqF "$rvm_bin_path " ; then
362
+ PATH="$rvm_bin_path:$PATH"
363
+ builtin hash -r
364
+ fi
365
+ }
366
+
357
367
  # Reset any rvm gathered information about the system and its state.
358
368
  # rvm will refresh the stored information the next time it is called after reset.
359
369
  __rvm_reset() {
360
- PATH="$(echo $PATH | \tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -)"
361
- PATH="$rvm_bin_path:$PATH" ; export PATH
370
+ __rvm_remove_rvm_from_path
371
+ __rvm_conditionally_add_bin_path
372
+ export PATH
373
+ builtin hash -r
362
374
 
363
375
  for flag in default passenger editor ; do \rm -f "$rvm_bin_path"/${flag}_* ; done
364
376
  unset flag
@@ -422,10 +434,8 @@ __rvm_initialize() {
422
434
 
423
435
  __rvm_clean_path
424
436
 
425
- if echo "$PATH" | \grep -q 'rvm\/bin:' ; then
426
- PATH="${rvm_bin_path}:$PATH"
427
- export PATH
428
- fi
437
+ __rvm_conditionally_add_bin_path
438
+ export PATH
429
439
 
430
440
  \mkdir -p "$rvm_src_path" "$rvm_bin_path" "$rvm_archives_path" "$rvm_gems_path" "$rvm_tmp_path" "$rvm_repo_path"
431
441
  }
@@ -462,7 +472,7 @@ __rvm_update_rvm() {
462
472
 
463
473
  __rvm_run "fetch" "$rvm_scripts_path/fetch 'http://rvm.beginrescueend.com/releases/rvm-${stable_version}.tar.gz'" "fetching rvm-${stable_version}.tar.gz"
464
474
 
465
- __rvm_run "extract" "cat $rvm_archives_path/rvm-${stable_version}.tar.gz | gunzip | tar xf - -C $rvm_src_path" "Extracting rvm-${stable_version}.tar.gz ..."
475
+ __rvm_run "extract" "gunzip \"$rvm_archives_path/rvm-${stable_version}.tar.gz\" | tar xf - -C $rvm_src_path" "Extracting rvm-${stable_version}.tar.gz ..."
466
476
 
467
477
  __rvm_run "install" "builtin cd $rvm_src_path/rvm-${stable_version}/ ; ./install" "Installing rvm-${stable_version}..."
468
478
  fi
@@ -531,12 +541,12 @@ __rvm_inspect() {
531
541
  for binary in $rvm_ruby_args ; do
532
542
  actual_file="$(command -v $binary)"
533
543
  $rvm_scripts_path/log "info" "$actual_file:"
534
- if [[ -n "$rvm_shebang_flag" ]] ; then cat $actual_file | head -n 1 ; fi
535
- if [[ -n "$rvm_env_flag" ]] ; then cat $actual_file | awk '/ENV/' ; fi
536
- if [[ -n "$rvm_path_flag" ]] ; then cat $actual_file | awk '/PATH/' ; fi
537
- if [[ -n "$rvm_head_flag" ]] ; then cat $actual_file | head -n 5 ; fi
538
- if [[ -n "$rvm_tail_flag" ]] ; then cat $actual_file | tail -n 5 ; fi
539
- if [[ -n "$rvm_all_flag" ]] ; then cat $actual_file ; fi
544
+ if [[ -n "$rvm_shebang_flag" ]] ; then head -n 1 < "$actual_file" ; fi
545
+ if [[ -n "$rvm_env_flag" ]] ; then awk '/ENV/' < "$actual_file" ; fi
546
+ if [[ -n "$rvm_path_flag" ]] ; then awk '/PATH/' < "$actual_file" ; fi
547
+ if [[ -n "$rvm_head_flag" ]] ; then head -n 5 < "$actual_file" ; fi
548
+ if [[ -n "$rvm_tail_flag" ]] ; then tail -n 5 < "$actual_file" ; fi
549
+ if [[ -n "$rvm_all_flag" ]] ; then cat $actual_file ; fi
540
550
  done
541
551
  }
542
552
 
@@ -580,6 +590,7 @@ __rvm_mono_env() {
580
590
  export ACLOCAL_FLAGS="-I $ACLOCAL_PATH"
581
591
  export PKG_CONFIG_PATH="$rvm_usr_path/lib/pkgconfig:$PKG_CONFIG_PATH"
582
592
  PATH="$rvm_usr_path/bin:$PATH"
593
+ builtin hash -r
583
594
  }
584
595
 
585
596
  __rvm_become() {
@@ -638,7 +649,7 @@ __rvm_current_gemcache_dir() {
638
649
  }
639
650
 
640
651
  __rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything() {
641
- for index in {1..750} ; do perl -e 'sleep 0.2'; echo -n '.' ; done ; printf "%d" 0x2A ; echo
652
+ for index in {1..750} ; do sleep 0.25 ; echo -n '.' ; done ; printf "%d" 0x2A ; echo
642
653
  }
643
654
 
644
655
  __rvm_ultimate_question() {
@@ -651,8 +662,9 @@ __rvm_ultimate_question() {
651
662
  __rvm_load_env_file() {
652
663
  if [[ -f "$rvm_environments_path/$1" ]]; then
653
664
  # Restore the path to it's state minus rvm
654
- PATH="$(echo $PATH | \tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -)"
655
- . "$rvm_environments_path/$1"
665
+ __rvm_remove_rvm_from_path
666
+ \. "$rvm_environments_path/$1"
667
+ builtin hash -r
656
668
  else
657
669
  rvm use "$1" >/dev/null 2>&1
658
670
  fi
@@ -720,7 +732,7 @@ __rvm_rvmrc_tools() {
720
732
  fi
721
733
  ;;
722
734
  load)
723
- rvm_trust_rvmrcs=1 __rvm_project_rvmrc "$(dirname "$rvmrc_path")"
735
+ rvm_rvmrc_cwd="" rvm_trust_rvmrcs=1 __rvm_project_rvmrc "$(dirname "$rvmrc_path")"
724
736
  ;;
725
737
  *)
726
738
  echo "Usage: rvm rvmrc {trust,untrust,trusted,load,reset}"
@@ -731,7 +743,7 @@ __rvm_rvmrc_tools() {
731
743
 
732
744
  __rvm_check_rvmrc_trustworthiness() {
733
745
  # Trust when they have the flag... of doom!
734
- [[ -z "$1" || "$rvm_trust_rvmrcs" = "1" ]] && return
746
+ [[ -z "$1" || "$rvm_trust_rvmrcs" = "1" ]] && return 0
735
747
  value="$(__rvm_rvmrc_stored_trust "$1")"
736
748
  if [[ -z "$value" ]] ; then
737
749
  __rvm_ask_to_trust "$1"
@@ -741,6 +753,7 @@ __rvm_check_rvmrc_trustworthiness() {
741
753
  }
742
754
 
743
755
  __rvm_ask_to_trust() {
756
+ [[ -n "$rvm_promptless" ]] && return 2
744
757
  echo "Changing into a directory with an untrusted .rvmrc"
745
758
  echo "Do you wish to trust the rvmrc in this directory? It contains:"
746
759
  echo "---"
@@ -775,7 +788,7 @@ __rvm_ask_to_trust() {
775
788
  __rvm_project_rvmrc() {
776
789
  local cwd
777
790
  # Get the first argument or the pwd.
778
- cwd="${1:-"$(pwd)"}"
791
+ cwd="${1:-"$PWD"}"
779
792
  while : ; do
780
793
  if [[ -z "$cwd" || "$HOME" = "$cwd" || "/" = "$cwd" ]] ; then
781
794
  if [[ -n "$rvm_rvmrc_cwd" ]] ; then
@@ -789,10 +802,15 @@ __rvm_project_rvmrc() {
789
802
  else
790
803
  if [[ -f "$cwd/.rvmrc" ]] ; then
791
804
  if [[ "$rvm_rvmrc_cwd" != "$cwd" ]] ; then
792
- if __rvm_check_rvmrc_trustworthiness "$cwd/.rvmrc" ; then
805
+ __rvm_check_rvmrc_trustworthiness "$cwd/.rvmrc"
806
+ local rvm_trustworthiness_result="$?"
807
+ if [[ "$rvm_trustworthiness_result" = 0 ]]; then
793
808
  rvm_previous_environment="$(__rvm_environment_identifier)"
794
809
  rvm_rvmrc_cwd="$cwd"
795
810
  source "$cwd/.rvmrc"
811
+ return 0
812
+ else
813
+ return "$rvm_trustworthiness_result"
796
814
  fi
797
815
  fi
798
816
  break
@@ -810,7 +828,7 @@ __rvm_record_install() {
810
828
  local rvm_install_command="$(echo "$recorded_ruby_name $rvm_install_arguments" | __rvm_strip)"
811
829
  \touch "$rvm_install_record_file"
812
830
  \rm -f "$rvm_install_record_file.tmp"
813
- cat "$rvm_install_record_file" | \grep -v "^$recorded_ruby_name " > "$rvm_install_record_file.tmp"
831
+ \grep -v "^$recorded_ruby_name " < "$rvm_install_record_file" > "$rvm_install_record_file.tmp"
814
832
  echo "$rvm_install_command" >> "$rvm_install_record_file.tmp"
815
833
  \rm -f "$rvm_install_record_file"
816
834
  mv "$rvm_install_record_file.tmp" "$rvm_install_record_file"
@@ -821,7 +839,7 @@ __rvm_remove_install_record() {
821
839
  local rvm_install_record_file="$rvm_config_path/installs"
822
840
  if [[ -s "$rvm_install_record_file" ]]; then
823
841
  mv "$rvm_install_record_file" "$rvm_install_record_file.tmp"
824
- cat "$rvm_install_record_file.tmp" | \grep -v "^$recorded_ruby_name " > "$rvm_install_record_file"
842
+ \grep -v "^$recorded_ruby_name " < "$rvm_install_record_file.tmp" > "$rvm_install_record_file"
825
843
  \rm -f "$rvm_install_record_file.tmp"
826
844
  fi
827
845
  }
@@ -831,7 +849,7 @@ __rvm_recorded_install_command() {
831
849
  [[ -z "$recorded_ruby_name" ]] && return 1
832
850
  local recorded_ruby_match="^$recorded_ruby_name "
833
851
  if [[ -s "$rvm_config_path/installs" ]] && \grep -q "$recorded_ruby_match" "$rvm_config_path/installs" ; then
834
- cat "$rvm_config_path/installs" | \grep "$recorded_ruby_match" | head -n1
852
+ \grep "$recorded_ruby_match" < "$rvm_config_path/installs" | head -n1
835
853
  else
836
854
  return 1
837
855
  fi
@@ -853,7 +871,7 @@ __rvm_expand_ruby_string() {
853
871
  elif [[ "$1" = "all-gemsets" ]]; then
854
872
  $rvm_scripts_path/list gemsets strings | __rvm_strip
855
873
  elif [[ "$1" = "default-with-rvmrc" || "$1" = "rvmrc" ]]; then
856
- $rvm_scripts_path/tools path-identifier "$(pwd)"
874
+ $rvm_scripts_path/tools path-identifier "$PWD"
857
875
  elif [[ "$1" == "all-rubies" || "$1" = "rubies" ]]; then
858
876
  $rvm_scripts_path/list rubies strings | __rvm_strip
859
877
  elif [[ "$1" == "current-ruby" || "$1" = "gemsets" ]]; then
@@ -862,8 +880,8 @@ __rvm_expand_ruby_string() {
862
880
  elif [[ "$1" = "current" ]]; then
863
881
  __rvm_environment_identifier
864
882
  elif [[ "$1" = "aliases" ]]; then
865
- cat "$rvm_config_path/alias" | awk -F= '{print $1}' | __rvm_strip
883
+ awk -F= '{print $1}' < "$rvm_config_path/alias" | __rvm_strip
866
884
  else
867
885
  echo "$1" | tr "," "\n" | __rvm_strip
868
886
  fi
869
- }
887
+ }