rvm 0.1.41 → 0.1.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/binscripts/rvm +1 -1
  2. data/binscripts/rvm-shell +32 -0
  3. data/binscripts/rvmsudo +1 -6
  4. data/config/db +2 -2
  5. data/config/known +2 -2
  6. data/config/md5 +6 -5
  7. data/contrib/install-system-wide +81 -0
  8. data/install +23 -24
  9. data/lib/VERSION.yml +1 -1
  10. data/lib/rvm.rb +156 -1
  11. data/lib/rvm/capistrano.rb +45 -0
  12. data/lib/rvm/environment.rb +62 -0
  13. data/lib/rvm/environment/alias.rb +69 -0
  14. data/lib/rvm/environment/cleanup.rb +54 -0
  15. data/lib/rvm/environment/configuration.rb +60 -0
  16. data/lib/rvm/environment/env.rb +52 -0
  17. data/lib/rvm/environment/gemset.rb +222 -0
  18. data/lib/rvm/environment/info.rb +13 -0
  19. data/lib/rvm/environment/list.rb +124 -0
  20. data/lib/rvm/environment/rubies.rb +50 -0
  21. data/lib/rvm/environment/sets.rb +123 -0
  22. data/lib/rvm/environment/tools.rb +41 -0
  23. data/lib/rvm/environment/utility.rb +167 -0
  24. data/lib/rvm/environment/wrapper.rb +23 -0
  25. data/lib/rvm/errors.rb +28 -0
  26. data/lib/rvm/shell.rb +21 -10
  27. data/lib/rvm/shell/abstract_wrapper.rb +145 -0
  28. data/lib/rvm/shell/result.rb +42 -0
  29. data/lib/rvm/shell/shell_wrapper.sh +10 -0
  30. data/lib/rvm/shell/single_shot_wrapper.rb +56 -0
  31. data/lib/rvm/shell/utility.rb +37 -0
  32. data/lib/rvm/version.rb +12 -8
  33. data/rvm.gemspec +27 -4
  34. data/scripts/cd +17 -32
  35. data/scripts/cli +46 -16
  36. data/scripts/completion +1 -1
  37. data/scripts/disk-usage +52 -0
  38. data/scripts/fetch +8 -2
  39. data/scripts/gemsets +15 -4
  40. data/scripts/initialize +3 -3
  41. data/scripts/install +23 -24
  42. data/scripts/list +16 -8
  43. data/scripts/log +4 -1
  44. data/scripts/man +0 -0
  45. data/scripts/manage +51 -34
  46. data/scripts/md5 +4 -5
  47. data/scripts/package +28 -6
  48. data/scripts/rubygems +2 -2
  49. data/scripts/rvm +2 -2
  50. data/scripts/rvm-install +23 -24
  51. data/scripts/selector +2 -2
  52. data/scripts/tools +34 -0
  53. data/scripts/update +23 -24
  54. data/scripts/utility +54 -12
  55. data/scripts/wrapper +21 -18
  56. metadata +29 -6
  57. data/lib/rvm/open4.rb +0 -395
  58. data/lib/rvm/rvm.rb +0 -14
@@ -44,19 +44,19 @@ if echo "$*" | grep -q 'trace' ; then echo "$*" ; env | grep '^rvm_' ; set -x ;
44
44
  while [[ $# -gt 0 ]] ; do
45
45
  token="$1" ; shift
46
46
  case "$token" in
47
- --auto) rvm_auto_flag=1 ;;
47
+ --auto) rvm_auto_flag=1 ;;
48
48
  --prefix) rvm_prefix="$1" ; shift ;;
49
49
  --version) rvm_path="$(pwd)" ; __rvm_version ; unset rvm_path ; exit ;;
50
- --help|*) usage ;;
50
+ --help|*) usage ;;
51
51
  esac
52
52
  done
53
53
 
54
54
  if [[ -z "$rvm_prefix" ]] ; then
55
55
  __rvm_load_rvmrc
56
56
  if [[ "root" = "$(whoami)" ]] ; then
57
- rvm_prefix="/usr/local/"
57
+ rvm_prefix="${rvm_prefix:-"/usr/local/"}"
58
58
  else
59
- rvm_prefix="$HOME/."
59
+ rvm_prefix="${rvm_prefix:-"$HOME/."}"
60
60
  fi
61
61
  fi
62
62
 
@@ -87,7 +87,7 @@ rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
87
87
  rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
88
88
  rvm_log_path="${rvm_log_path:-"$rvm_path/log"}"
89
89
 
90
- if [[ "root" = "$(whoami)" ]] ; then
90
+ if [[ -z "$rvm_prefix" ]] && [[ "root" = "$(whoami)" ]] ; then
91
91
  rvm_bin_path="${rvm_bin_path:-"/usr/local/bin"}"
92
92
  else
93
93
  rvm_bin_path="${rvm_bin_path:-"$rvm_path/bin"}"
@@ -114,7 +114,7 @@ fi
114
114
 
115
115
  spinner
116
116
 
117
- mkdir -p $rvm_archives_path $rvm_src_path $rvm_log_path $rvm_bin_path $rvm_gems_path $rvm_rubies_path $rvm_config_path $rvm_hooks_path $rvm_tmp_path
117
+ mkdir -p $rvm_archives_path $rvm_src_path $rvm_log_path $rvm_bin_path $rvm_gems_path $rvm_rubies_path $rvm_config_path $rvm_hooks_path $rvm_patches_path $rvm_tmp_path
118
118
 
119
119
  for file in README LICENCE ; do
120
120
  spinner
@@ -139,7 +139,7 @@ if [[ ! -s "$rvm_config_path/user" ]] ; then
139
139
  fi
140
140
 
141
141
  scripts=("monitor" "match" "log" "install" "color" "db" "fetch" "log" "set" "package")
142
- for script_name in $scripts ; do
142
+ for script_name in "${scripts[@]}" ; do
143
143
  spinner
144
144
  chmod +x $rvm_scripts_path/$script_name
145
145
  done
@@ -148,7 +148,7 @@ done
148
148
  # Bin Scripts
149
149
  #
150
150
  # Cleanse and purge...
151
- for file in rvm-prompt rvm rvmsudo ; do
151
+ for file in rvm-prompt rvm rvmsudo rvm-shell ; do
152
152
  spinner && perl -e 'sleep 0.2'
153
153
  rm -f "$rvm_bin_path/$file"
154
154
  cp -f "$source_path/binscripts/$file" $rvm_bin_path/
@@ -160,7 +160,7 @@ chmod +x $rvm_bin_path/*
160
160
  # RC Files
161
161
  #
162
162
  spinner
163
- if [[ ! -z "$rvm_auto_flag" ]] ; then
163
+ if [[ -n "$rvm_auto_flag" ]] ; then
164
164
  printf "Checking rc files... ($rvm_rc_files)"
165
165
  if [[ "$rvm_loaded_flag" != "1" ]] ; then
166
166
  for rcfile in $(echo $rvm_rc_files) ; do
@@ -274,16 +274,16 @@ fi
274
274
  # End of gemset migration.
275
275
  #
276
276
 
277
- if [[ "root" = "$(whoami)" ]] ; then
278
- printf "\n Symlinking rvm to $rvm_bin_path/rvm ..."
279
- mkdir -p $rvm_bin_path
280
- chmod +x $rvm_bin_path/rvm
281
- chmod +x $rvm_bin_path/rvmsudo
282
- printf "\n Copying manpages into place."
283
- for man_file in $(\ls "$install_source_path/man"); do
284
- cp -f "$install_source_path/man/$man_file" "$rvm_man_path/$man_file"
285
- done
286
- fi
277
+ printf "\n Correct permissions for base binaries in $rvm_bin_path..."
278
+ mkdir -p $rvm_bin_path
279
+ for file in rvm rvmsudo rvm-shell ; do
280
+ [[ -s "$rvm_bin_path/$file" ]] && chmod +x "$rvm_bin_path/$file"
281
+ done; unset file
282
+ printf "\n Copying manpages into place."
283
+ for man_file in $(\ls "$install_source_path/man"); do
284
+ rm -rf "$rvm_man_path/$man_file"
285
+ cp -R "$install_source_path/man/$man_file" "$rvm_man_path/"
286
+ done
287
287
 
288
288
  if [[ "$upgrade_flag" -eq 0 ]] ; then
289
289
  ./scripts/notes
@@ -303,20 +303,19 @@ if [[ "$upgrade_flag" -eq 1 ]] ; then
303
303
  printf "\n$(tput setaf 6)Upgrade Notes\n"
304
304
  printf "\n * 'rvm notes' tells you OS dependency packages for installing rubies."
305
305
  printf "\n * If you encounter any issues with a ruby your best bet is to 'rvm remove X ; rvm install X' "
306
- printf "\n * 1.8.7 default patchlevel is p174, override ~/.rvm/config/db in ~/.rvm/config/user"
307
306
  printf "\n * Gemset separator is '@' and will remain unless any rubies error using it."
308
307
  printf "\n$(tput sgr0)\n"
309
308
  check_rubyopt_conditions
310
309
  printf "\nUpgrade of RVM in $rvm_path/ is complete.\n\n"
311
310
  else
312
- if [[ "root" != "$(whoami)" ]] ; then
311
+ if [[ -z "$rvm_prefix" ]] && [[ "root" != "$(whoami)" ]] ; then
313
312
  printf "\n$(tput setaf 1)You must now finish the install manually:$(tput sgr0)"
314
313
  printf "\n1) Place the folowing line at the end of your shell's loading files(.bashrc or .bash_profile for bash and .zshrc for zsh), after all path/variable settings:"
315
314
  printf "\n [[ -s \$HOME/.rvm/scripts/rvm ]] && source \$HOME/.rvm/scripts/rvm"
316
315
  printf "\n Please note that this must only occur once - so, you only need to add it the first time you install rvm."
317
316
  printf "\n2) Ensure that there is no 'return' from inside the .bashrc file. (otherwise rvm will be prevented from working properly)."
318
- printf "\n This means that if you see '[ -z "$PS1" ] && return' then you must change this line to:"
319
- printf "\n if [[ ! -z "$PS1" ]] ; then"
317
+ printf "\n This means that if you see '[ -z "\$PS1" ] && return' then you must change this line to:"
318
+ printf "\n if [[ -n "\$PS1" ]] ; then"
320
319
  printf "\n ... original content that was below the && return line ..."
321
320
  printf "\n fi # <= be sure to close the if."
322
321
  printf "\n #EOF .bashrc"
@@ -325,7 +324,7 @@ else
325
324
  printf "\n placing all non-interactive items in the .bashrc, including the 'source' line above"
326
325
  printf "\n3) Then $(tput setaf 1)CLOSE THIS SHELL$(tput sgr0) and open a new one in order to use rvm.\n"
327
326
  fi
328
- if [[ -s $HOME/.bashrc ]] && grep '&& return' $HOME/.bashrc ; then
327
+ if [[ -s $HOME/.bashrc ]] && grep -q '&& return' $HOME/.bashrc ; then
329
328
  printf "\n\nWARNING: you have a 'return' statement in your .bashrc, likely this will cause untold havoc."
330
329
  printf "\n This means that if you see '[ -z "\$PS1" ] && return' then you must change this line to:"
331
330
  printf "\n if [[ -n "\$PS1" ]] ; then"
@@ -303,8 +303,8 @@ __rvm_use() {
303
303
 
304
304
  if [[ ! -z "$rvm_default_flag" ]] && [[ "default" != "$rvm_ruby_interpreter" ]] ; then
305
305
  if [[ "root" = "$(whoami)" ]] ; then
306
- # By not providing the name it uses the base ruby binary names.
307
- $rvm_scripts_path/wrapper $rvm_ruby_string
306
+ # Sets up the default wrappers.
307
+ $rvm_scripts_path/wrapper "$rvm_ruby_string"
308
308
  fi
309
309
  if [[ "system" = "$rvm_ruby_interpreter" ]] ; then
310
310
  $rvm_scripts_path/alias delete default &> /dev/null
@@ -0,0 +1,34 @@
1
+ source "$rvm_scripts_path/base"
2
+
3
+ usage() {
4
+ echo "Usage: rvm tools {identifier,path-identifier}" 1>&2
5
+ exit 1
6
+ }
7
+
8
+ # Return the identifier that's current in use.
9
+ tools_identifier() {
10
+ __rvm_environment_identifier
11
+ }
12
+
13
+ tools_path_identifier() {
14
+ if [[ -z "$1" || ! -d "$1" ]]; then
15
+ echo "Usage: rvm tools path-identifier 'path-to-heck'"
16
+ return 1
17
+ fi
18
+ # Change to the directory. Do in subshell to keep the env correct.
19
+ (source $rvm_scripts_path/rvm
20
+ cd "$1" >/dev/null 2>&1
21
+ __rvm_environment_identifier)
22
+ }
23
+
24
+ [[ -z "$1" ]] && usage
25
+
26
+ action="$1"; shift
27
+
28
+ case "$action" in
29
+ identifier) tools_identifier ;;
30
+ path-identifier) tools_path_identifier "$@" ;;
31
+ *) usage ;;
32
+ esac
33
+
34
+ exit $?
@@ -44,19 +44,19 @@ if echo "$*" | grep -q 'trace' ; then echo "$*" ; env | grep '^rvm_' ; set -x ;
44
44
  while [[ $# -gt 0 ]] ; do
45
45
  token="$1" ; shift
46
46
  case "$token" in
47
- --auto) rvm_auto_flag=1 ;;
47
+ --auto) rvm_auto_flag=1 ;;
48
48
  --prefix) rvm_prefix="$1" ; shift ;;
49
49
  --version) rvm_path="$(pwd)" ; __rvm_version ; unset rvm_path ; exit ;;
50
- --help|*) usage ;;
50
+ --help|*) usage ;;
51
51
  esac
52
52
  done
53
53
 
54
54
  if [[ -z "$rvm_prefix" ]] ; then
55
55
  __rvm_load_rvmrc
56
56
  if [[ "root" = "$(whoami)" ]] ; then
57
- rvm_prefix="/usr/local/"
57
+ rvm_prefix="${rvm_prefix:-"/usr/local/"}"
58
58
  else
59
- rvm_prefix="$HOME/."
59
+ rvm_prefix="${rvm_prefix:-"$HOME/."}"
60
60
  fi
61
61
  fi
62
62
 
@@ -87,7 +87,7 @@ rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
87
87
  rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
88
88
  rvm_log_path="${rvm_log_path:-"$rvm_path/log"}"
89
89
 
90
- if [[ "root" = "$(whoami)" ]] ; then
90
+ if [[ -z "$rvm_prefix" ]] && [[ "root" = "$(whoami)" ]] ; then
91
91
  rvm_bin_path="${rvm_bin_path:-"/usr/local/bin"}"
92
92
  else
93
93
  rvm_bin_path="${rvm_bin_path:-"$rvm_path/bin"}"
@@ -114,7 +114,7 @@ fi
114
114
 
115
115
  spinner
116
116
 
117
- mkdir -p $rvm_archives_path $rvm_src_path $rvm_log_path $rvm_bin_path $rvm_gems_path $rvm_rubies_path $rvm_config_path $rvm_hooks_path $rvm_tmp_path
117
+ mkdir -p $rvm_archives_path $rvm_src_path $rvm_log_path $rvm_bin_path $rvm_gems_path $rvm_rubies_path $rvm_config_path $rvm_hooks_path $rvm_patches_path $rvm_tmp_path
118
118
 
119
119
  for file in README LICENCE ; do
120
120
  spinner
@@ -139,7 +139,7 @@ if [[ ! -s "$rvm_config_path/user" ]] ; then
139
139
  fi
140
140
 
141
141
  scripts=("monitor" "match" "log" "install" "color" "db" "fetch" "log" "set" "package")
142
- for script_name in $scripts ; do
142
+ for script_name in "${scripts[@]}" ; do
143
143
  spinner
144
144
  chmod +x $rvm_scripts_path/$script_name
145
145
  done
@@ -148,7 +148,7 @@ done
148
148
  # Bin Scripts
149
149
  #
150
150
  # Cleanse and purge...
151
- for file in rvm-prompt rvm rvmsudo ; do
151
+ for file in rvm-prompt rvm rvmsudo rvm-shell ; do
152
152
  spinner && perl -e 'sleep 0.2'
153
153
  rm -f "$rvm_bin_path/$file"
154
154
  cp -f "$source_path/binscripts/$file" $rvm_bin_path/
@@ -160,7 +160,7 @@ chmod +x $rvm_bin_path/*
160
160
  # RC Files
161
161
  #
162
162
  spinner
163
- if [[ ! -z "$rvm_auto_flag" ]] ; then
163
+ if [[ -n "$rvm_auto_flag" ]] ; then
164
164
  printf "Checking rc files... ($rvm_rc_files)"
165
165
  if [[ "$rvm_loaded_flag" != "1" ]] ; then
166
166
  for rcfile in $(echo $rvm_rc_files) ; do
@@ -274,16 +274,16 @@ fi
274
274
  # End of gemset migration.
275
275
  #
276
276
 
277
- if [[ "root" = "$(whoami)" ]] ; then
278
- printf "\n Symlinking rvm to $rvm_bin_path/rvm ..."
279
- mkdir -p $rvm_bin_path
280
- chmod +x $rvm_bin_path/rvm
281
- chmod +x $rvm_bin_path/rvmsudo
282
- printf "\n Copying manpages into place."
283
- for man_file in $(\ls "$install_source_path/man"); do
284
- cp -f "$install_source_path/man/$man_file" "$rvm_man_path/$man_file"
285
- done
286
- fi
277
+ printf "\n Correct permissions for base binaries in $rvm_bin_path..."
278
+ mkdir -p $rvm_bin_path
279
+ for file in rvm rvmsudo rvm-shell ; do
280
+ [[ -s "$rvm_bin_path/$file" ]] && chmod +x "$rvm_bin_path/$file"
281
+ done; unset file
282
+ printf "\n Copying manpages into place."
283
+ for man_file in $(\ls "$install_source_path/man"); do
284
+ rm -rf "$rvm_man_path/$man_file"
285
+ cp -R "$install_source_path/man/$man_file" "$rvm_man_path/"
286
+ done
287
287
 
288
288
  if [[ "$upgrade_flag" -eq 0 ]] ; then
289
289
  ./scripts/notes
@@ -303,20 +303,19 @@ if [[ "$upgrade_flag" -eq 1 ]] ; then
303
303
  printf "\n$(tput setaf 6)Upgrade Notes\n"
304
304
  printf "\n * 'rvm notes' tells you OS dependency packages for installing rubies."
305
305
  printf "\n * If you encounter any issues with a ruby your best bet is to 'rvm remove X ; rvm install X' "
306
- printf "\n * 1.8.7 default patchlevel is p174, override ~/.rvm/config/db in ~/.rvm/config/user"
307
306
  printf "\n * Gemset separator is '@' and will remain unless any rubies error using it."
308
307
  printf "\n$(tput sgr0)\n"
309
308
  check_rubyopt_conditions
310
309
  printf "\nUpgrade of RVM in $rvm_path/ is complete.\n\n"
311
310
  else
312
- if [[ "root" != "$(whoami)" ]] ; then
311
+ if [[ -z "$rvm_prefix" ]] && [[ "root" != "$(whoami)" ]] ; then
313
312
  printf "\n$(tput setaf 1)You must now finish the install manually:$(tput sgr0)"
314
313
  printf "\n1) Place the folowing line at the end of your shell's loading files(.bashrc or .bash_profile for bash and .zshrc for zsh), after all path/variable settings:"
315
314
  printf "\n [[ -s \$HOME/.rvm/scripts/rvm ]] && source \$HOME/.rvm/scripts/rvm"
316
315
  printf "\n Please note that this must only occur once - so, you only need to add it the first time you install rvm."
317
316
  printf "\n2) Ensure that there is no 'return' from inside the .bashrc file. (otherwise rvm will be prevented from working properly)."
318
- printf "\n This means that if you see '[ -z "$PS1" ] && return' then you must change this line to:"
319
- printf "\n if [[ ! -z "$PS1" ]] ; then"
317
+ printf "\n This means that if you see '[ -z "\$PS1" ] && return' then you must change this line to:"
318
+ printf "\n if [[ -n "\$PS1" ]] ; then"
320
319
  printf "\n ... original content that was below the && return line ..."
321
320
  printf "\n fi # <= be sure to close the if."
322
321
  printf "\n #EOF .bashrc"
@@ -325,7 +324,7 @@ else
325
324
  printf "\n placing all non-interactive items in the .bashrc, including the 'source' line above"
326
325
  printf "\n3) Then $(tput setaf 1)CLOSE THIS SHELL$(tput sgr0) and open a new one in order to use rvm.\n"
327
326
  fi
328
- if [[ -s $HOME/.bashrc ]] && grep '&& return' $HOME/.bashrc ; then
327
+ if [[ -s $HOME/.bashrc ]] && grep -q '&& return' $HOME/.bashrc ; then
329
328
  printf "\n\nWARNING: you have a 'return' statement in your .bashrc, likely this will cause untold havoc."
330
329
  printf "\n This means that if you see '[ -z "\$PS1" ] && return' then you must change this line to:"
331
330
  printf "\n if [[ -n "\$PS1" ]] ; then"
@@ -24,6 +24,17 @@ __rvm_teardown() {
24
24
  # Ruby strings are scoped to their action.
25
25
  # Hence, we ensure we remove them at in
26
26
  # the cleanup phase.
27
+
28
+ # Clean up after CC switch
29
+ if [[ -n "$rvm_clang_flag" ]] ; then
30
+ if [[ -n "$rvm_prior_cc" ]] ; then
31
+ export CC="$rvm_prior_cc"
32
+ else
33
+ unset CC
34
+ fi
35
+ unset rvm_prior_cc
36
+ fi
37
+
27
38
  unset rvm_ruby_strings
28
39
  }
29
40
 
@@ -65,8 +76,8 @@ is_a_function() { type $1 | head -n 1 | grep -q "function" ; }
65
76
  __rvm_quote_args() {
66
77
  local quoted_string=""
67
78
  for quoted_argument in "$@"; do
68
- if echo "$quoted_argument" | grep -q " "; then
69
- quoted_string="$quoted_string '$(echo "$quoted_argument" | sed "s/'/\\\'/g")'"
79
+ if printf "%s" "$quoted_argument" | grep -vq "^[[:alnum:]]$"; then
80
+ quoted_string="$quoted_string '$(printf "%s" "$quoted_argument" | sed "s/'/\'\\\'\'/g")'"
70
81
  else
71
82
  quoted_string="$quoted_string $quoted_argument"
72
83
  fi
@@ -169,7 +180,7 @@ __rvm_cleanup_variables() {
169
180
 
170
181
  if [[ "$rvm_sticky_flag" = "1" ]] ; then export rvm_gemset_name ; else unset rvm_gemset_name ; fi
171
182
 
172
- unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_url 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_ruby_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_ruby_aliases rvm_patch_names
183
+ unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_url 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_ruby_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_ruby_aliases rvm_patch_names rvm_clang_flag
173
184
  }
174
185
 
175
186
  # Unset ruby-specific variables
@@ -498,9 +509,9 @@ __rvm_make_flags() {
498
509
  # \ls /usr/lib/gcc/x86_64-apple-darwin10
499
510
 
500
511
  # Set the build & host type
501
- if [[ "Power Macintosh" = "$(sysctl hw.machine | awk -F: '{print $2}' | sed 's/^ //')" ]] ; then
512
+ if [[ "Power Macintosh" = "$(sysctl -n hw.machine)" ]] ; then
502
513
  : # Do nothing ?
503
- elif [[ $(sysctl hw.cpu64bit_capable | awk '{print $2}') = 1 ]] ; then # we could also use: sysctl hw.optional.x86_64
514
+ elif [[ "$(sysctl -n hw.cpu64bit_capable)" = 1 || "$(sysctl -n hw.optional.x86_64)" = 1 ]] ; then
504
515
  # 64 bit capable
505
516
  if [[ "-arch x86_64" = "$rvm_archflags" ]] ; then
506
517
  rvm_ruby_configure_flags="${rvm_ruby_configure_flags} --build=x86_64-apple-darwin$(uname -r) --host=x86_64-apple-darwin$(uname -r)"
@@ -510,10 +521,6 @@ __rvm_make_flags() {
510
521
  rvm_archflags="-arch x86_64"
511
522
  rvm_ruby_configure_flags="${rvm_ruby_configure_flags} --build=x86_64-apple-darwin$(uname -r) --host=x86_64-apple-darwin$(uname -r)"
512
523
  fi
513
- else
514
- # 32 bit capable only
515
- if [[ -z "$rvm_archflags" ]] ; then rvm_archflags="-arch i386" ; fi
516
- rvm_ruby_configure_flags="${rvm_ruby_configure_flags} --build=i386-apple-darwin$(uname -r) --host=i386-apple-darwin$(uname -r)"
517
524
  fi
518
525
 
519
526
  if [[ ! -z "$rvm_archflags" ]] ; then
@@ -705,14 +712,16 @@ __rvm_ensure_has_enviroment_files() {
705
712
  fi ; unset file_name
706
713
  # Next, ensure we have default wrapper files. Also, prevent it from recursing.
707
714
  if [[ -z "$rvm_creating_default_wrappers" ]]; then
715
+ # We need to generate wrappers for both the default gemset and the global gemset.
716
+ for wrapper_identifier in "$environment_identifier" "${environment_identifier}@global" ; do
708
717
  rvm_creating_default_wrappers=1
709
- directory_name="$rvm_wrappers_path/$environment_identifier"
718
+ directory_name="$rvm_wrappers_path/$wrapper_identifier"
710
719
  if [[ ! -L "$directory_name" && ! -d "$directory_name" ]]; then
711
720
  mkdir -p "$directory_name"
712
- # Install the default wrappers.
713
- $rvm_scripts_path/wrapper "$environment_identifier" &> /dev/null
721
+ $rvm_scripts_path/wrapper "$wrapper_identifier" &> /dev/null
714
722
  fi
715
723
  unset rvm_creating_default_wrappers directory_name
724
+ done; unset wrapper_identifier
716
725
  fi
717
726
  }
718
727
 
@@ -744,3 +753,36 @@ __rvm_ultimate_question() {
744
753
  printf "\nUltimate Question."
745
754
  }
746
755
 
756
+ # Checks the rvmrc for the given directory. Note that if
757
+ # argument is passed, it will be used instead of pwd.
758
+ __rvm_project_rvmrc() {
759
+ local cwd
760
+ # Get the first argument or the pwd.
761
+ cwd="${1:-"$(pwd)"}"
762
+ while : ; do
763
+ if [[ -z "$cwd" ]] || [[ "$HOME" = "$cwd" ]] || [[ "/" = "$cwd" ]] ; then
764
+ if [[ -n "$rvm_rvmrc_cwd" ]] ; then
765
+ if [[ -z "$rvm_previous_environment" ]] ; then
766
+ rvm default 1>/dev/null 2>&1
767
+ else
768
+ rvm "$rvm_previous_environment" 1>/dev/null 2>&1
769
+ fi
770
+ unset rvm_rvmrc_cwd rvm_previous_environment
771
+ fi
772
+ break
773
+ else
774
+ if [[ -f "$cwd/.rvmrc" ]] ; then
775
+ if [[ "$rvm_rvmrc_cwd" != "$cwd" ]] ; then
776
+ if [[ -z "$rvm_previous_environment" ]] ; then
777
+ rvm_previous_environment="$(__rvm_environment_identifier)"
778
+ fi
779
+ rvm_rvmrc_cwd="$cwd"
780
+ source "$cwd/.rvmrc"
781
+ fi
782
+ break
783
+ else
784
+ cwd=$(dirname "$cwd")
785
+ fi
786
+ fi
787
+ done
788
+ }
@@ -28,18 +28,21 @@ wrap() {
28
28
 
29
29
  symlink_binary() {
30
30
  # Generate the default wrapper with the given binary name.
31
- wrap_binary # Note, now forcing this every time to force clean.
32
- # Then symlink it into place.
33
- rm -f "${rvm_bin_path}/${prefix}_${binary_name}"
34
- ln -fs "$file_name" "${rvm_bin_path}/${prefix}_${binary_name}"
31
+ # We first check if we can wrap the binary and if we were able to,
32
+ # we then symlink it into place.
33
+ if wrap_binary && [[ -f "$file_name" ]]; then
34
+ rm -f "${rvm_bin_path}/${prefix}_${binary_name}"
35
+ ln -fs "$file_name" "${rvm_bin_path}/${prefix}_${binary_name}"
36
+ fi
35
37
  }
36
38
 
37
39
  wrap_binary() {
38
- # Iff the command is found in the path.
39
- if command -v $binary_name > /dev/null; then
40
+ # We wrap when the given binary is in the path or override_check is set to one.
41
+ if [[ "$override_check" = "1" ]] || command -v $binary_name > /dev/null; then
40
42
  wrap
41
43
  else
42
44
  $rvm_scripts_path/log "error" "Binary '$binary_name' not found in path."
45
+ return 1
43
46
  fi
44
47
  }
45
48
 
@@ -58,8 +61,9 @@ fi
58
61
 
59
62
  ruby_string="$1"; shift
60
63
 
64
+ override_check=0
61
65
  prefix="$1"
62
- if [[ -n "$1" ]]; then shift; fi
66
+ [[ "$#" -gt 0 ]] && shift
63
67
 
64
68
  binaries="$(echo "$@" | __rvm_strip)"
65
69
 
@@ -85,19 +89,18 @@ environment_identifier="$(__rvm_environment_identifier)"
85
89
  for binary_name in $binaries; do
86
90
  file_name="${rvm_wrappers_path}/${environment_identifier}/${binary_name}"
87
91
  if [[ -z "$prefix" ]] ; then
92
+ override_check=1
88
93
  wrap_binary
89
94
  # Symlink it into place.
90
- if [[ "$binary_name" == "ruby" ]] ; then
91
- rm -f "${rvm_bin_path}/${environment_identifier}"
92
- ln -nsf "${file_name}" "${rvm_bin_path}/${environment_identifier}"
93
- else
94
- rm -f "${rvm_bin_path}/${binary_name}-${environment_identifier}"
95
- ln -nsf "${file_name}" "${rvm_bin_path}/${binary_name}-${environment_identifier}"
96
- fi
97
- if [[ "root" = "$(whoami)" ]] && [[ "${default_flag}" = 1 ]] ; then
98
- rm -f "${rvm_bin_path}/${binary_name}"
99
- ln -nsf "${file_name}" "${rvm_bin_path}/${binary_name}"
100
- fi
95
+ if [[ -f "$file_name" ]]; then
96
+ if [[ "$binary_name" == "ruby" ]] ; then
97
+ destination="$rvm_bin_path/$environment_identifier"
98
+ else
99
+ destination="$rvm_bin_path/${binary_name}-${environment_identifier}"
100
+ fi
101
+ rm -rf "$destination"
102
+ ln -nsf "$file_name" "$destination"
103
+ fi; unset destination
101
104
  else
102
105
  symlink_binary
103
106
  fi ; unset file_name