rvm 0.0.48 → 0.0.49

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ function __rvm_select {
6
6
  __rvm_ruby_string
7
7
  elif [ ! -z "$rvm_ruby_selector" ] ; then
8
8
  if [ ! -z "$(echo $rvm_ruby_selector | awk '/^[0-9]/')" ] ; then
9
- rvm_ruby_interpreter="ruby"
9
+ rvm_ruby_interpreter="${rvm_ruby_interpreter:-ruby}"
10
10
  rvm_ruby_version=$rvm_ruby_selector
11
11
  else
12
12
  rvm_ruby_interpreter="$rvm_ruby_selector"
@@ -17,7 +17,6 @@ function __rvm_select {
17
17
  rvm_ruby_version=$rvm_ruby_interpreter
18
18
  rvm_ruby_interpreter="ruby"
19
19
  else
20
- rvm_ruby_interpreter="${1:-$rvm_ruby_interpreter}"
21
20
  rvm_ruby_interpreter="${rvm_ruby_interpreter:-ruby}" # Default is standard ruby
22
21
  fi
23
22
  fi
@@ -45,6 +44,7 @@ function __rvm_select {
45
44
  unset rvm_ruby_patch_level
46
45
  rvm_ruby_interpreter="rubinius"
47
46
  rvm_ruby_repo_url=`__rvm_db "rubinius_repo_url"`
47
+ rvm_url=$rvm_ruby_repo_url
48
48
  rvm_ruby_configure=""
49
49
  rvm_ruby_make="build"
50
50
  rvm_ruby_make_install=""
@@ -54,7 +54,7 @@ function __rvm_select {
54
54
  jruby)
55
55
  rvm_ruby_version="${rvm_ruby_version:-`__rvm_db "jruby_version"`}"
56
56
  unset rvm_ruby_patch_level
57
- if [ "$rvm_ruby_version" != "1.2.0" -a "$rvm_ruby_version" != "1.3.1" ] ; then
57
+ if [ ! -z "$(echo $rvm_ruby_version | awk '/^1\.2\.0/')" -o ! -z "$(rvm_ruby_version | awk '/^1\.3\.[0-3]/')" ] ; then
58
58
  __rvm_log "fail" "Unknown jRuby version: $rvm_ruby_version"
59
59
  fi
60
60
  alias jruby_ng="jruby --ng"
@@ -66,8 +66,7 @@ function __rvm_select {
66
66
  rvm_ruby_interpreter=`__rvm_db "ree_interpreter"`
67
67
  rvm_ruby_version=${rvm_ruby_version:-`__rvm_db "ree_version"`}
68
68
  rvm_ruby_patch_level="${3:-`__rvm_db "ree_patch_level"`}"
69
-
70
- if [ "$rvm_ruby_version" != "1.8.6" ] ; then
69
+ if [ -z "$(echo $rvm_ruby_version | awk '/^1\.8/')" ] ; then
71
70
  __rvm_log "fail" "Unknown Ruby Enterprise Edition version: $rvm_ruby_version"
72
71
  fi
73
72
  ;;
@@ -239,3 +238,30 @@ function __rvm_use {
239
238
  if [ ! -z "$rvm_dump_flag" ] ; then __rvm_gemset_dump ; fi
240
239
  }
241
240
 
241
+ function __rvm_ruby_string {
242
+ if [ "$rvm_ruby_interpreter" = "system" ] ; then
243
+ rvm_ruby_string="system"
244
+ elif [ ! -z "$rvm_ruby_string" ] ; then
245
+ rvm_ruby_string=`echo "$rvm_ruby_string" | sed 's/ruby-enterprise/ree/g'` # dash-antics :)
246
+ rvm_ruby_interpreter=`echo $rvm_ruby_string | tr '-' ' ' | awk '{print $1}'`
247
+ rvm_ruby_version=`echo $rvm_ruby_string | awk -F'-' '{print $2}'`
248
+ revision=`echo $rvm_ruby_string | awk -F'-' '{print $3}'`
249
+
250
+ if [ "$revision" = "head" -o "$revision" = "preview" ] ; then
251
+ rvm_ruby_revision="$revision"
252
+ else
253
+ echo $revision | grep '^p[0-9]\+' > /dev/null
254
+ if [ $? -eq 0 ] ; then
255
+ rvm_ruby_patch_level=`echo $revision | awk -F'p' '{print $2}'`
256
+ else
257
+ echo $revision | grep '^[0-9]\+' > /dev/null
258
+ if [ $? -eq 0 ] ; then
259
+ rvm_ruby_rev="$revision"
260
+ else
261
+ unset rvm_ruby_patch_level rvm_ruby_rev
262
+ fi
263
+ fi
264
+ fi
265
+ fi
266
+ return 0
267
+ }
data/scripts/update ADDED
@@ -0,0 +1,173 @@
1
+ #!/bin/bash
2
+
3
+ user=`whoami`
4
+ if [ "$user" = "root" ] ; then
5
+ echo -e "\033[0;31m <e> \033[0mroot user support is not yet implemented.\033[0m"
6
+ exit 1
7
+ fi
8
+
9
+ item="\033[0;32m* \033[0m"
10
+ question="\n\033[0;32m<?>\033[0m"
11
+ cwd=$(pwd)
12
+ source_dir="${source_dir:-`dirname $0 | xargs dirname`}"
13
+ if [ ! -d "$source_dir" ] ; then unset source_dir ; fi
14
+ source_dir="${source_dir:-$cwd}"
15
+ rvm_dir=~/.rvm
16
+
17
+ # State what is required to use rvm
18
+ echo -e "\n\033[0;32mrvm\033[0m\n\n shell scripts that allows a user to manage multiple ruby versions in their own account."
19
+ echo -e "\n Installing rvm to ~/.rvm/ ..."
20
+ for dir_name in src scripts bin log archives config gems examples ; do
21
+ mkdir -p $rvm_dir/$dir_name
22
+ done
23
+
24
+ for dir_name in config scripts examples lib ; do
25
+ mkdir -p $rvm_dir/$dir_name
26
+ /bin/cp -Rf $source_dir/$dir_name $rvm_dir
27
+ done ; unset dir_name
28
+
29
+ for file_name in rvm-prompt gemsync ; do
30
+ mv $rvm_dir/scripts/$file_name $rvm_dir/bin/
31
+ chmod +x $rvm_dir/bin/$file_name
32
+ done ; unset file_name
33
+
34
+ results=$(grep 'scripts/rvm' ~/.bash_profile ~/.bashrc ~/.zshrc > /dev/null)
35
+ if [ $? -gt 0 ] ; then
36
+ if [ ! -z "`echo $PS1`" ] ; then
37
+ while : ; do
38
+ echo -n -e "$question Do you want this (s)cript to set this up for you, or do it (m)anually yourself ('s' or 'm')? "
39
+ read response
40
+ if [ "${response:0:1}" = "s" ] ; then
41
+ echo 'w00t!'
42
+ break
43
+ elif [ "${response:0:1}" = "m" ] ; then
44
+ echo -e " Please make sure that this line is in place."
45
+ break
46
+ fi
47
+ done
48
+
49
+ if [ "${response:0:1}" = "s" ] ; then
50
+
51
+ while : ; do
52
+ echo -n -e "$question Do you use b(a)sh or (z)sh or b(o)th for your shell (the default on most *nix systems is bash, press control + C to cancel the installation)\n(a/z/o)? "
53
+ read response
54
+ if [ "${response:0:1}" = "a" ] ; then
55
+ user_shell="bash"
56
+ break
57
+ elif [ "${response:0:1}" = "z" ] ; then
58
+ user_shell="zsh"
59
+ break
60
+ elif [ "${response:0:1}" = "o" ] ; then
61
+ user_shell="both"
62
+ break
63
+ fi
64
+ done
65
+ fi
66
+ else
67
+ user_shell="both"
68
+ fi
69
+
70
+ if [ "$user_shell" = "bash" -o "$user_shell" = "both" ] ; then
71
+ touch ~/.bash_profile
72
+ if [ -z "`grep '\.rvm/scripts/rvm' ~/.bash_profile`" ] ; then
73
+ echo "Adding 'if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi' to your ~/.bash_profile."
74
+ echo -e "\n" >> ~/.bash_profile
75
+ echo "if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi" >> ~/.bash_profile
76
+ fi
77
+ touch ~/.bashrc
78
+ if [ -z "`grep '\.rvm/scripts/rvm' ~/.bashrc`" ] ; then
79
+ echo "Adding 'if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi' to your ~/.bashrc."
80
+ echo -e "\n" >> ~/.bashrc
81
+ echo "if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi" >> ~/.bashrc
82
+ fi
83
+
84
+ fi
85
+
86
+ if [ "$user_shell" = "zsh" -o "$user_shell" = "both" ] ; then
87
+ touch ~/.zshrc
88
+ if [ -z "`grep '\.rvm/scripts/rvm' ~/.zshrc`" ] ; then
89
+ echo "Adding 'if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi' to your ~/.zshrc."
90
+ echo -e "\n" >> ~/.zshrc
91
+ echo "if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi" >> ~/.zshrc
92
+ fi
93
+ fi
94
+ fi
95
+
96
+ echo -e "\n Ensuring that rvm script location in $file is scripts/rvm not bin/rvm for: ~/.bash_profile, ~/.bashrc, ~/.zshrc..."
97
+ for file in ~/.bash_profile ~/.bashrc ~/.zshrc ; do
98
+ if [ -s $file ] ; then
99
+ if [ -L $file ] ; then # If the file is a symlink,
100
+ actual_file=`readlink $file` # read the link target so we can preserve it.
101
+ else
102
+ actual_file="$file"
103
+ fi
104
+
105
+ grep 'rvm\/bin\/rvm' $actual_file > /dev/null
106
+ if [ $? -eq 0 ] ; then
107
+ sed -i.orig 's/rvm\/bin\/rvm/rvm\/scripts\/rvm/g' $actual_file
108
+ rm -f $actual_file.orig
109
+ fi
110
+
111
+ if [ -f ~/.profile ] ; then
112
+ grep '.profile' $actual_file > /dev/null
113
+ if [ $? -gt 0 ] ; then
114
+ profile=~/.profile
115
+ echo -e "\n" >> $actual_file
116
+ echo "source $profile" >> $actual_file
117
+ fi
118
+ fi
119
+ fi
120
+ done
121
+
122
+ if [ -f ~/.rvm/bin/rvm ] ; then
123
+ echo -e "\n Removing old rvm file from ~/.rvm/bin/rvm..."
124
+ rm -f ~/.rvm/bin/rvm
125
+ fi
126
+
127
+ system=`uname`
128
+ echo -e "\n \033[0;33mNOTES: \033[0m"
129
+ if [ "$system" = "Linux" ] ; then
130
+ rvm_apt_get_binary=`which apt-get 2> /dev/null`
131
+ rvm_emerge_binary=`which emerge 2> /dev/null`
132
+ rvm_pacman_binary=`which pacman 2> /dev/null`
133
+ rvm_yum_binary=`which yum 2> /dev/null`
134
+
135
+ if [ ! -z "$rvm_apt_get_binary" ] ; then
136
+ echo -e " $item For jRuby (if you wish to use it) you will need:"
137
+ echo -e " $ sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk"
138
+ echo -e " $item For ree (if you wish to use it) you will need:"
139
+ echo -e " $ sudo apt-get install libreadline5-dev libssl-dev bison"
140
+
141
+ elif [ ! -z "$rvm_emerge_binary" ] ; then
142
+ echo -e " $item For jRuby (if you wish to use it) you will need:"
143
+ echo -e " $ sudo emerge dev-java/sun-jdk dev-java/sun-jre-bin"
144
+
145
+ elif [ ! -z "$rvm_pacman_binary" ] ; then
146
+ echo -e " $item For jRuby (if you wish to use it) you will need:"
147
+ echo -e " $ sudo pacman -Sy jdk jre"
148
+
149
+ elif [ ! -z "$rvm_yum_binary" ] ; then
150
+ echo -e " $item For ree (if you wish to use it) you will need:"
151
+ echo -e " $ yum install -y rpm-build gcc gcc-c++ redhat-rpm-config ; then download and rpmbuild and install the sdk, Have fun..."
152
+
153
+ else
154
+ echo -e " $item For jRuby (if you wish to use it) you will need:"
155
+ echo -e " The SUN java runtime environment and development kit."
156
+ fi
157
+ elif [ "$system" = "Darwin" ] ; then
158
+ echo -e " $item Be sure that you have XCode Tools installed in order to use rvm."
159
+ echo -e " $item If you intend on installing MacRuby you must install LLVM first."
160
+ fi
161
+
162
+ echo -e " $item In order to use rvm the following line must occur in your shell's loading files, after all path/variable settings.:"
163
+ echo -e " $item if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi"
164
+ echo -e " $item CLOSE THIS SHELL AND OPEN A NEW ONE in order to use rvm."
165
+
166
+ echo -e "\n \033[0;33mRTFM: \033[0m http://rvm.beginrescueend.com/ \n"
167
+ echo -e '\033[0;32mw⦿‿⦿t!\033[0m'
168
+ echo -e "\n ~ Wayne\n"
169
+
170
+ source $rvm_dir/scripts/rvm
171
+ rvm -v
172
+ echo
173
+
@@ -93,11 +93,11 @@ function __rvm_run {
93
93
  }
94
94
 
95
95
  function __rvm_cleanup_variables {
96
- unset rvm_selected rvm_action rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_irbrc_file rvm_ruby_irbrc rvm_source_path rvm_path rvm_prefix_path rvm_ruby_package_name rvm_gem_path rvm_command rvm_error_message rvm_ruby_home rvm_ruby_binary rvm_gem_set_name rvm_ruby_tag rvm_ruby_rev rvm_url rvm_ruby_make rvm_ruby_configure rvm_ruby_make_install rvm_config_path rvm_ruby_string rvm_bin_path rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_load_flag rvm_dump_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
96
+ unset rvm_selected rvm_action rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_irbrc_file rvm_ruby_irbrc rvm_source_path rvm_path rvm_prefix_path rvm_ruby_package_name rvm_gem_path rvm_command rvm_error_message rvm_ruby_home rvm_ruby_binary rvm_gem_set_name rvm_ruby_tag rvm_ruby_rev rvm_url rvm_ruby_make rvm_ruby_configure rvm_ruby_make_install rvm_config_path rvm_ruby_string rvm_bin_path rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_load_flag rvm_dump_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_ruby_string rvm_ruby_selector rvm_shebang_flag rvm_env_flag rvm_head_flag rvm_tail_flag
97
97
  }
98
98
 
99
99
  function __rvm_unset_ruby_variables {
100
- unset rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_configure rvm_ruby_make rvm_ruby_make_install rvm_ruby_rev rvm_ruby_tag rvm_major_version rvm_minor_version rvm_gem_set_name rvm_gem_home rvm_ruby_binary rvm_ruby_package_name rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_selected rvm_ruby_selector
100
+ unset rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_configure rvm_ruby_make rvm_ruby_make_install rvm_ruby_rev rvm_ruby_tag rvm_major_version rvm_minor_version rvm_gem_set_name rvm_gem_home rvm_ruby_binary rvm_ruby_package_name rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_selected rvm_ruby_selector rvm_ruby_string
101
101
  }
102
102
 
103
103
  # TODO: root user loadng of /etc/rvmrc
@@ -128,34 +128,53 @@ PATH=$rvm_ruby_home/bin:$rvm_gem_home/bin:\$PATH ; export PATH
128
128
  exec "$rvm_ruby_binary" "\$@"
129
129
  RubyWrapper
130
130
  )
131
- echo "$ruby_wrapper" > $rvm_bin_path/$rvm_ruby_package_name
131
+ rm -f $rvm_path/bin/$rvm_ruby_package_name
132
+ echo "$ruby_wrapper" > $rvm_path/bin/$rvm_ruby_package_name
132
133
  unset ruby_wrapper
133
- chmod +x $rvm_bin_path/$rvm_ruby_package_name
134
+ chmod +x $rvm_path/bin/$rvm_ruby_package_name
134
135
  }
135
136
 
136
137
  function __rvm_fetch {
137
-
138
138
  __rvm_pushpop $rvm_archives_path
139
- eval $rvm_fetch "$1"
140
- result=$?
141
- if [ $result -gt 0 ] ; then
142
- if [ $result -eq 78 ] ; then
143
- __rvm_log "error" "The requested url does not exist: '$1'"
144
- elif [ $result -eq 33 ] ; then
145
- archive=`basename "$1"`
146
- __rvm_log "debug" "Server does not support 'range' command, removing '$archive'"
147
- rm -f $archive ; unset archive
148
- __rvm_fetch "$1"
139
+ archive=`basename "$1"`
140
+ __rvm_log "debug" "Fetching $archive"
141
+ # Check first if we have the correct archive
142
+ if [ -e $archive ] && [ -e $archive.md5 ] ; then
143
+ __rvm_log "debug" "Found archive and its md5, testing correctness"
144
+ if [ `md5sum --status -c $archive.md5` -gt 0 ] ; then
145
+ __rvm_log "debug" "Archive is bad, downloading"
146
+ download=1
149
147
  else
150
- __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
148
+ __rvm_log "debug" "Archive is good, not downloading"
149
+ download=0
150
+ result=0
151
151
  fi
152
+ else
153
+ __rvm_log "debug" "No archive or no MD5, downloading"
154
+ download=1
152
155
  fi
153
- __rvm_pushpop
156
+ if [ $download -gt 0 ] ; then
157
+ eval $rvm_fetch "$1"
158
+ result=$?
159
+ if [ $result -gt 0 ] ; then
160
+ if [ $result -eq 78 ] ; then
161
+ __rvm_log "error" "The requested url does not exist: '$1'"
162
+ elif [ $result -eq 33 ] ; then
163
+ __rvm_log "debug" "Server does not support 'range' command, removing '$archive'"
164
+ rm -f $archive
165
+ __rvm_fetch "$1"
166
+ else
167
+ __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
168
+ fi
169
+ fi
170
+ __rvm_pushpop
171
+ fi
172
+ unset archive
173
+ unset download
154
174
  return $result
155
175
  }
156
176
 
157
177
  function __rvm_load_defaults {
158
-
159
178
  if [ ! -s $rvm_path/system ] ; then
160
179
  for variable in RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME ; do
161
180
  eval value=\$${variable}
@@ -196,11 +215,9 @@ function __rvm_load_defaults {
196
215
  fi
197
216
  fi
198
217
  fi
199
-
200
218
  }
201
219
 
202
220
  function __rvm_reset {
203
-
204
221
  PATH=$(echo $PATH | tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -)
205
222
  PATH=$rvm_bin_path:$PATH ; export PATH
206
223
 
@@ -216,7 +233,6 @@ function __rvm_reset {
216
233
  done ; unset system_config variable
217
234
 
218
235
  rm -f $rvm_path/bin/ruby $rvm_path/bin/gem $rvm_path/bin/rake $rvm_path/bin/irb $rvm_path/bin/default*
219
-
220
236
  }
221
237
 
222
238
  function __rvm_implode {
@@ -323,7 +339,6 @@ function __rvm_db {
323
339
  }
324
340
 
325
341
  function __rvm_list {
326
-
327
342
  if [ "$rvm_all_flag" ] ; then
328
343
  svn list http://svn.ruby-lang.org/repos/ruby/tags/ | grep 'v1_[8|9]' | sed 's/^v1_//' | sed 's/\/$//' | awk -F'_' '{print "1."$1"."$2 " -l "$3}' | sed 's/p$//'
329
344
 
@@ -336,7 +351,8 @@ function __rvm_list {
336
351
  echo "rbx head --jit"
337
352
  echo "ree 20090610"
338
353
  else
339
- current=`which ruby | xargs dirname | xargs dirname | xargs basename`
354
+ current=`which ruby | xargs dirname | xargs dirname | xargs basename 2> /dev/null`
355
+
340
356
  echo -e "\nruby:\n"
341
357
  for version in `/bin/ls -l $rvm_path/ 2> /dev/null | awk '/ ruby-[1-2].*/ { print $NF }'` ; do
342
358
  string=`$rvm_bin_path/$version -v`
@@ -387,10 +403,10 @@ function __rvm_list {
387
403
  echo -e "\nsystem:\n"
388
404
  system_version=`rvm system ; ruby -v 2> /dev/null`
389
405
  if [ ! -z "$system_version" ] ; then
390
- if [ "$selected" = "1" ] ; then
391
- echo -e " $system_version\n"
392
- else
406
+ if [ "$(`which ruby` -v)" = "$system_version" ] ; then
393
407
  echo -e "=> $system_version\n"
408
+ else
409
+ echo -e " $system_version\n"
394
410
  fi
395
411
  fi ; unset current version selected
396
412
  fi
@@ -460,9 +476,9 @@ function __rvm_update_rvm {
460
476
  mkdir -p $rvm_source_path
461
477
  if [ "$rvm_ruby_rev" = "head" ] ; then
462
478
  if [ -d $rvm_source_path/rvm/.git ] ; then
463
- cd $rvm_source_path/rvm/ && git pull origin master && ./scripts/rvm-install
479
+ cd $rvm_source_path/rvm/ && git pull origin master && ./scripts/install
464
480
  else
465
- cd $rvm_source_path && git clone git://github.com/wayneeseguin/rvm.git && cd rvm/ && ./scripts/rvm-install
481
+ cd $rvm_source_path && git clone git://github.com/wayneeseguin/rvm.git && cd rvm/ && ./install
466
482
  fi
467
483
  else
468
484
  # TODO: rvm_install_path:
@@ -485,7 +501,7 @@ function __rvm_reboot {
485
501
  fi
486
502
  fi
487
503
  gem install rvm --no-rdoc --no-ri -q
488
- which rvm-install > /dev/null
504
+ which rvm-install 2> /dev/null
489
505
  if [ $? -gt 0 ] ; then
490
506
  if [ -e ~/.gem/ruby/1.8/bin/rvm-install ] ; then
491
507
  ~/.gem/ruby/1.8/bin/rvm-install
@@ -535,7 +551,8 @@ function __rvm_ruby_do {
535
551
  }
536
552
 
537
553
  function __rvm_do {
538
- # TODO: Extract the outer looping mechanism with rvm_install's
554
+ __rvm_state
555
+
539
556
  rubies=() ; successes=() ; errors=() ; statuses=()
540
557
  # TODO: Extract the common functionality out of the if below
541
558
  if [ ! -z "$rvm_ruby_string" ] ; then
@@ -563,6 +580,8 @@ function __rvm_do {
563
580
  if [ ! -z "$rvm_yaml_flag" ] ; then __rvm_yaml ; fi
564
581
  if [ ! -z "$rvm_json_flag" ] ; then __rvm_json ; fi
565
582
 
583
+ __rvm_state
584
+
566
585
  return ${#errors[*]}
567
586
  }
568
587
 
@@ -641,34 +660,6 @@ RubyCode
641
660
  __rvm_do
642
661
  }
643
662
 
644
- function __rvm_ruby_string {
645
- if [ "$rvm_ruby_interpreter" = "system" ] ; then
646
- rvm_ruby_string="system"
647
- elif [ ! -z "$rvm_ruby_string" ] ; then
648
- rvm_ruby_string=`echo "$rvm_ruby_string" | sed 's/ruby-enterprise/ree/g'` # dash-antics :)
649
- rvm_ruby_interpreter=`echo $rvm_ruby_string | tr '-' ' ' | awk '{print $1}'`
650
- rvm_ruby_version=`echo $rvm_ruby_string | awk -F'-' '{print $2}'`
651
- revision=`echo $rvm_ruby_string | awk -F'-' '{print $3}'`
652
-
653
- if [ "$revision" = "head" -o "$revision" = "preview" ] ; then
654
- rvm_ruby_revision="$revision"
655
- else
656
- echo $revision | grep '^p[0-9]\+' > /dev/null
657
- if [ $? -eq 0 ] ; then
658
- rvm_ruby_patch_level=`echo $revision | awk -F'p' '{print $2}'`
659
- else
660
- echo $revision | grep '^[0-9]\+' > /dev/null
661
- if [ $? -eq 0 ] ; then
662
- rvm_ruby_rev="$revision"
663
- else
664
- unset rvm_ruby_patch_level rvm_ruby_rev
665
- fi
666
- fi
667
- fi
668
- fi
669
- return 0
670
- }
671
-
672
663
  function __rvm_gemset_dump {
673
664
  file_name=${rvm_gem_set_name:-'default'}
674
665
 
@@ -811,3 +802,31 @@ function __rvm_iconv_install {
811
802
  __rvm_pushpop
812
803
  }
813
804
 
805
+ function __rvm_state {
806
+ if [ -z "$rvm_state" ] ; then
807
+ if [ -z "$(which ruby | awk /`basename $rvm_path`/)" ] ; then
808
+ rvm_state=system
809
+ else
810
+ rvm_state="$(dirname `which ruby` | xargs dirname | xargs basename)"
811
+ fi
812
+ else
813
+ rvm_ruby_string="$rvm_state"
814
+ __rvm_select
815
+ __rvm_use
816
+ unset rvm_state
817
+ fi
818
+ }
819
+
820
+ function __rvm_inspect {
821
+ for binary in $rvm_ruby_args ; do
822
+ actual_file=`which $binary`
823
+ __rvm_log "info" "$actual_file:"
824
+ if [ ! -z "$rvm_shebang_flag" ] ; then cat $actual_file | head -n 1 ; fi
825
+ if [ ! -z "$rvm_env_flag" ] ; then cat $actual_file | awk '/ENV/' ; fi
826
+ if [ ! -z "$rvm_path_flag" ] ; then cat $actual_file | awk '/PATH/' ; fi
827
+ if [ ! -z "$rvm_head_flag" ] ; then cat $actual_file | head -n 5 ; fi
828
+ if [ ! -z "$rvm_tail_flag" ] ; then cat $actual_file | tail -n 5 ; fi
829
+ if [ ! -z "$rvm_all_flag" ] ; then cat $actual_file ; fi
830
+ done
831
+ }
832
+