rvm 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/binscripts/rvm CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- if [[ -z "$rvm_ignore_rvmrc" ]]; then
3
+ rvm_ignore_rvmrc=${rvm_ignore_rvmrc:-0}
4
+ if [[ $rvm_ignore_rvmrc -eq 0 ]]; then
4
5
  for rvmrc in /etc/rvmrc "$HOME/.rvmrc" ; do
5
6
  if [[ -f "$rvmrc" ]] ; then
6
7
  if \grep -q '^\s*rvm .*$' "$rvmrc" ; then
@@ -48,6 +49,6 @@ rvm_scripts_path="${rvm_scripts_path:-"$rvm_path/scripts"}"
48
49
 
49
50
  source "$rvm_scripts_path/rvm"
50
51
 
51
- unset rvm_interactive
52
+ unset rvm_interactive_flag
52
53
 
53
54
  rvm "$@"
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- if [[ -z "$rvm_ignore_rvmrc" ]]; then
3
+ rvm_ignore_rvmrc=${rvm_ignore_rvmrc:-0}
4
+ if [[ $rvm_ignore_rvmrc -eq 0 ]]; then
4
5
  [[ -s /etc/rvmrc ]] && source /etc/rvmrc
5
6
  [[ -s "$HOME/.rvmrc" ]] && source "$HOME/.rvmrc"
6
7
  fi
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- if [[ -z "$rvm_ignore_rvmrc" ]]; then
3
+ rvm_ignore_rvmrc=${rvm_ignore_rvmrc:-0}
4
+ if [[ $rvm_ignore_rvmrc -eq 0 ]]; then
4
5
  [[ -s /etc/rvmrc ]] && source /etc/rvmrc
5
6
  [[ -s "$HOME/.rvmrc" ]] && source "$HOME/.rvmrc"
6
7
  fi
data/binscripts/rvmsudo CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  prefix="PATH='$PATH'"
4
- if [[ ! -z "$BUNDLE_PATH" ]] ; then prefix="BUNDLE_PATH='$BUNDLE_PATH' $prefix" ; fi
5
- if [[ ! -z "$GEM_HOME" ]] ; then prefix="GEM_HOME='$GEM_HOME' $prefix" ; fi
6
- if [[ ! -z "$GEM_PATH" ]] ; then prefix="GEM_PATH='$GEM_PATH' $prefix" ; fi
4
+ if [[ -n "${BUNDLE_PATH:-""}" ]] ; then prefix="BUNDLE_PATH='$BUNDLE_PATH' $prefix" ; fi
5
+ if [[ -n "${GEM_HOME:-""}" ]] ; then prefix="GEM_HOME='$GEM_HOME' $prefix" ; fi
6
+ if [[ -n "${GEM_PATH:-""}" ]] ; then prefix="GEM_PATH='$GEM_PATH' $prefix" ; fi
7
7
 
8
8
  eval "sudo" "/usr/bin/env $prefix $@"
9
9
  # rvm_env_prefix="PATH='$PATH'"
@@ -21,7 +21,8 @@ elif [[ "$(uname)" != "Linux" ]]; then
21
21
  fi
22
22
 
23
23
  # Load the rvm config.
24
- if [[ -z "$rvm_ignore_rvmrc" ]]; then
24
+ rvm_ignore_rvmrc=${rvm_ignore_rvmrc:-0}
25
+ if [[ $rvm_ignore_rvmrc -eq 0 ]]; then
25
26
  [[ -s /etc/rvmrc ]] && source /etc/rvmrc
26
27
  [[ -s "$HOME/.rvmrc" ]] && source "$HOME/.rvmrc"
27
28
  fi
data/install CHANGED
@@ -201,7 +201,7 @@ fi
201
201
  spinner
202
202
  if [[ -d gemsets/ ]] ; then
203
203
  \mkdir -p "$rvm_gemsets_path"
204
- for gemset_file in $(cd gemsets ; find \. -iname '*.gems' | sed 's/^\.\///') ; do
204
+ for gemset_file in $(builtin cd gemsets ; find \. -iname '*.gems' | sed 's/^\.\///') ; do
205
205
  destination="$rvm_gemsets_path/$gemset_file"
206
206
  destination_path="$(dirname "$destination")"
207
207
  if [[ ! -s "$destination" ]] ; then
@@ -214,7 +214,7 @@ fi
214
214
  spinner
215
215
  if [[ -d patchsets/ ]] ; then
216
216
  \mkdir -p "$rvm_patchsets_path"
217
- for patchset_file in $(cd patchsets ; find \. -iname '*' | sed 's/^\.\///') ; do
217
+ for patchset_file in $(builtin cd patchsets ; find \. -iname '*' | sed 's/^\.\///') ; do
218
218
  destination="$rvm_patchsets_path/$patchset_file"
219
219
  destination_path="$(dirname "$destination")"
220
220
  if [[ ! -s "$destination" ]] ; then
@@ -318,6 +318,7 @@ if [[ "$upgrade_flag" -eq 1 ]] ; then
318
318
  printf "\n * 'rvm notes' tells you OS dependency packages for installing rubies."
319
319
  printf "\n * If you encounter any issues with a ruby your best bet is to 'rvm remove X ; rvm install X' "
320
320
  printf "\n * Gemset separator is '@' and will remain unless any rubies error using it."
321
+ printf "\n * If you wish to have the 'pretty colors' again, set 'export rvm_pretty_print=1' in ~/.rvmrc.\n"
321
322
  printf "\n$(tput sgr0)\n"
322
323
  check_rubyopt_conditions
323
324
  printf "\nUpgrade of RVM in $rvm_path/ is complete.\n\n"
data/lib/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 0
4
- :patch: 2
4
+ :patch: 3
data/rvm.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rvm}
8
- s.version = "1.0.2"
8
+ s.version = "1.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wayne E. Seguin"]
12
- s.date = %q{2010-09-03}
12
+ s.date = %q{2010-09-06}
13
13
  s.default_executable = %q{rvm-install}
14
14
  s.description = %q{Manages Ruby interpreter environments and switching between them.}
15
15
  s.email = %q{wayneeseguin@gmail.com}
@@ -125,7 +125,6 @@ Gem::Specification.new do |s|
125
125
  "scripts/list",
126
126
  "scripts/log",
127
127
  "scripts/maglev",
128
- "scripts/man",
129
128
  "scripts/manage",
130
129
  "scripts/match",
131
130
  "scripts/md5",
data/scripts/alias CHANGED
@@ -47,16 +47,21 @@ show_alias() {
47
47
  delete_alias() {
48
48
  echo "Deleting alias: $alias_name"
49
49
  for link in "$rvm_rubies_path/$alias_name" ; do
50
- if [[ -L "$link" ]] ; then \rm -f $link ; fi
50
+ if [[ -L "$link" ]] ; then rm -f $link ; fi
51
51
  done
52
52
  "$rvm_scripts_path"/db "$rvm_config_path/alias" "$alias_name" "delete"
53
53
  }
54
54
 
55
55
  create_alias() {
56
+ rvm_environment_identifier="${rvm_environment_identifier:-""}"
57
+ alias_name="${alias_name:-""}"
58
+ rvm_ruby_string="${rvm_ruby_string:-""}"
59
+
56
60
  if alias_conflicts_with_ruby "$alias_name"; then
57
61
  # Force it to an empty alias name to trigger the usage.
58
62
  alias_name=""
59
63
  fi
64
+
60
65
  if [[ -z "$rvm_environment_identifier" ]] || [[ -z "$alias_name" ]] ; then
61
66
  "$rvm_scripts_path"/log "error" "usage: 'rvm alias [alias_name] [ruby_string]'"
62
67
  result=1
@@ -100,11 +105,14 @@ alias_list() {
100
105
  done; unset item
101
106
  }
102
107
 
103
- action="$1"
104
- alias_name="$2"
105
- rvm_environment_identifier="$3"
106
- if [[ ! -f "$rvm_config_path/alias" ]] ; then \touch "$rvm_config_path/alias" ; fi
107
- if printf "$alias_name" | \grep -q "$rvm_gemset_separator" ; then
108
+ args=($*)
109
+ action="${args[0]}"
110
+ alias_name="${args[1]}"
111
+ rvm_environment_identifier="${args[2]}"
112
+ args="$(echo ${args[@]:3}) " # Strip trailing / leading / extra spacing.
113
+
114
+ if [[ ! -f "$rvm_config_path/alias" ]] ; then touch "$rvm_config_path/alias" ; fi
115
+ if printf "$alias_name" | grep -q "$rvm_gemset_separator" ; then
108
116
  gemset_name="${alias_name/*${rvm_gemset_separator}/}"
109
117
  alias_name="${alias_name/${rvm_gemset_separator}*/}"
110
118
  fi
data/scripts/array CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- if [[ ! -z "$ZSH_VERSION" ]] ; then __array_start=1 ; else __array_start=0 ; fi
3
+ if [[ -n "${ZSH_VERSION:-""}" ]] ; then __array_start=1 ; else __array_start=0 ; fi
4
4
 
5
5
  # Usage: contains "a_string" "${an_array[@]}"
6
6
  array_contains() {
data/scripts/cd CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  # Source a .rvmrc file in a directory after changing to it, if it exists.
4
4
  # To disable this fature, set rvm_project_rvmrc=0 in $HOME/.rvmrc
5
- if [[ "$rvm_project_rvmrc" -ne 0 ]] ; then
6
- if [[ -n "$ZSH_VERSION" ]]; then
5
+ rvm_project_rvmrc=${rvm_project_rvmrc:-1}
6
+ if [[ $rvm_project_rvmrc -ne 0 ]] ; then
7
+ if [[ -n "${ZSH_VERSION:-""}" ]] ; then
7
8
  autoload is-at-least
8
9
  if is-at-least 4.3.4 >/dev/null 2>&1; then
9
10
  # On zsh, use chpwd_functions
data/scripts/cleanup CHANGED
@@ -13,7 +13,7 @@ cleanup() {
13
13
  eval "current_path=\"\$rvm_${cleanup_type}_path\""
14
14
  if [[ -n "$current_path" && -d "$current_path" && "$current_path" != "/" ]]; then
15
15
  "$rvm_scripts_path"/log "info" "Cleaning up rvm directory '$current_path'"
16
- \rm -rf "$current_path"/* >/dev/null 2>&1
16
+ rm -rf "$current_path"/* >/dev/null 2>&1
17
17
  fi
18
18
  done; unset cleanup_type current_path
19
19
  }
data/scripts/cli CHANGED
@@ -16,8 +16,17 @@ __rvm_parse_args() {
16
16
 
17
17
  if echo "$@" | \grep -q 'trace' ; then echo "$@" ; __rvm_version ; fi
18
18
 
19
+ rvm_action="${rvm_action:-""}"
20
+ export rvm_ruby_string="${rvm_ruby_string:-""}"
21
+
22
+ local rvm_parse_break=0
23
+ local rvm_error_message=""
24
+
19
25
  while [[ $# -gt 0 ]] ; do
20
- rvm_token="$1" ; shift
26
+ rvm_token="$next_token" ; shift
27
+
28
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; else next_token="" ; fi
29
+
21
30
  case "$rvm_token" in
22
31
  fetch|version|srcdir|reset|debug|reload|update|monitor|notes|implode|seppuku|question|answer|env)
23
32
  rvm_action=$rvm_token
@@ -25,17 +34,17 @@ __rvm_parse_args() {
25
34
 
26
35
  package)
27
36
  rvm_action="$rvm_token"
28
- if [[ "$1" = "--only-path" ]]; then
37
+ if [[ "$next_token" = "--only-path" ]]; then
29
38
  shift; rvm_only_path_flag=1
30
39
  fi
31
- rvm_ruby_args="$@"
40
+ rvm_ruby_args="$*"
32
41
  rvm_parse_break=1
33
42
  ;;
34
43
 
35
44
  use)
36
45
  rvm_action="$rvm_token"
37
46
  rvm_verbose_flag=1
38
- if [[ "ruby" = "$1" ]] ; then shift ; fi
47
+ if [[ "ruby" = "$next_token" ]] ; then shift ; fi
39
48
  ;;
40
49
 
41
50
  install|uninstall)
@@ -56,7 +65,7 @@ __rvm_parse_args() {
56
65
  rvm_ruby_string="$rvm_token"
57
66
  rvm_ruby_strings="$rvm_token"
58
67
  rvm_action="${rvm_action:-use}"
59
- if "$rvm_scripts_path"/match "$1" "^[0-9]\.[0-9]" ; then rvm_ruby_version=$1 ; shift ; fi
68
+ if "$rvm_scripts_path"/match "$next_token" "^[0-9]\.[0-9]" ; then rvm_ruby_version=$next_token ; shift ; fi
60
69
  ;;
61
70
 
62
71
  gemset)
@@ -64,13 +73,15 @@ __rvm_parse_args() {
64
73
 
65
74
  rvm_ruby_gem_home="$GEM_HOME"
66
75
 
67
- if [[ "clear" = "$1" ]] ; then
76
+ if [[ -z "$next_token" ]] ; then
77
+ rvm_ruby_args="help"
78
+ elif [[ "clear" = "$next_token" ]] ; then
68
79
  __rvm_gemset_clear
69
80
  rvm_ruby_args="clear"
70
- elif [[ "use" = "$1" ]] ; then
81
+ elif [[ "use" = "$next_token" ]] ; then
71
82
  rvm_use_flag=1
72
83
  rvm_ruby_args="$@" ; shift
73
- rvm_gemset_name="$1" ; shift
84
+ rvm_gemset_name="$next_token" ; shift
74
85
  if [[ ! -z "$(echo $rvm_gemset_name | \grep $rvm_gemset_separator)" ]] ; then
75
86
  rvm_ruby_string=$(echo $rvm_gemset_name | sed 's/\(.*\)'${rvm_gemset_separator}'.*/\1/')
76
87
  rvm_gemset_name=$(echo $rvm_gemset_name | sed 's/.*'${rvm_gemset_separator}'\(.*\)/\1/')
@@ -79,10 +90,10 @@ __rvm_parse_args() {
79
90
  fi
80
91
  rvm_ruby_gem_home="$rvm_ruby_gem_home${rvm_gemset_separator}$rvm_gemset_name"
81
92
  fi
82
- elif [[ "delete" = "$1" ]] ; then
93
+ elif [[ "delete" = "$next_token" ]] ; then
83
94
  rvm_delete_flag=1
84
95
  rvm_ruby_args="$@" ; shift
85
- rvm_gemset_name="$1"; shift
96
+ rvm_gemset_name="$next_token"; shift
86
97
  if echo "$rvm_gemset_name" | \grep -q "$rvm_gemset_separator" ; then
87
98
  rvm_ruby_string=$(echo "$rvm_gemset_name" | sed 's/\(.*\)'${rvm_gemset_separator}'.*/\1/')
88
99
  rvm_gemset_name=$(echo "$rvm_gemset_name" | sed 's/.*'${rvm_gemset_separator}'\(.*\)/\1/')
@@ -92,6 +103,7 @@ __rvm_parse_args() {
92
103
  rvm_ruby_gem_home="$rvm_ruby_gem_home${rvm_gemset_separator}$rvm_gemset_name"
93
104
  fi
94
105
  else
106
+ rvm_gemset_name="${rvm_gemset_name:-""}"
95
107
  if [[ "$rvm_ruby_string" != "$rvm_gemset_name" ]] ; then __rvm_ruby_string ; fi
96
108
  rvm_ruby_args="$@"
97
109
  fi
@@ -101,11 +113,11 @@ __rvm_parse_args() {
101
113
  gemdir|gempath|gemhome)
102
114
  rvm_action=$rvm_token
103
115
  rvm_gemdir_flag=1
104
- if [[ "system" = "$1" ]] ; then rvm_system_flag=1 ; shift ; fi
105
- if [[ "user" = "$1" ]] ; then rvm_user_flag=1 ; shift ; fi
116
+ if [[ "system" = "$next_token" ]] ; then rvm_system_flag=1 ; shift ; fi
117
+ if [[ "user" = "$next_token" ]] ; then rvm_user_flag=1 ; shift ; fi
106
118
  ;;
107
119
 
108
- inspect|list|info)
120
+ inspect|list|info|strings)
109
121
  rvm_action="$rvm_token"
110
122
  rvm_ruby_args="$@"
111
123
  rvm_parse_break=1
@@ -142,15 +154,15 @@ __rvm_parse_args() {
142
154
  ;;
143
155
 
144
156
  do|ruby|rake|gem|rubydo|rakedo|gemdo)
145
- if [[ "do" = "$rvm_action" ]] ; then rvm_action="ruby" ; fi
157
+ if [[ "do" = "${rvm_action:-""}" ]] ; then rvm_action="ruby" ; fi
146
158
  rvm_action=$(echo $rvm_token | sed 's#do##g')
147
- if [[ "rake" = "$rvm_action" ]] || [[ "gem" = "$rvm_action" ]] || [[ "ruby" = "$rvm_action" ]] ; then
148
- if [[ -z "$1" ]] ; then
149
- if [[ "gem" = "$rvm_action" ]] ; then
159
+ if [[ "rake" = "${rvm_action:-""}" || "gem" = "${rvm_action:-""}" || "ruby" = "${rvm_action:-""}" ]] ; then
160
+ if [[ -z "$next_token" ]] ; then
161
+ if [[ "gem" = "${rvm_action:-""}" ]] ; then
150
162
  rvm_action="error"
151
163
  rvm_error_message="'rvm $rvm_action' must be followed by arguments."
152
- elif [[ "ruby" = "$rvm_action" ]] ; then
153
- if echo "$rvm_ruby_strings" | \grep -q ',' ; then
164
+ elif [[ "ruby" = "${rvm_action:-""}" ]] ; then
165
+ if echo "$rvm_ruby_strings":-""} | \grep -q ',' ; then
154
166
  rvm_action="ruby"
155
167
  rvm_ruby_args=""
156
168
  else
@@ -158,11 +170,11 @@ __rvm_parse_args() {
158
170
  rvm_error_message="rvm X,Y,Z '$rvm_action' must be followed by arguments."
159
171
  fi
160
172
  fi
161
- elif [[ "-S" = "$1" ]] ; then
173
+ elif [[ "-S" = "$next_token" ]] ; then
162
174
  rvm_action="ruby"
163
175
  rvm_ruby_args="$flag $(__rvm_quote_args "$@")"
164
176
  rvm_parse_break=1
165
- elif [[ "-e" = "$1" ]] ; then
177
+ elif [[ "-e" = "$next_token" ]] ; then
166
178
  rvm_action="ruby"
167
179
  rvm_ruby_args="$flag $(__rvm_quote_args "$@")"
168
180
  rvm_parse_break=1
@@ -171,16 +183,16 @@ __rvm_parse_args() {
171
183
  rvm_parse_break=1
172
184
  fi
173
185
  else
174
- if "$rvm_scripts_path"/match "$1" "^-" ; then
186
+ if "$rvm_scripts_path"/match "$next_token" "^-" ; then
175
187
  unset rvm_ruby_strings
176
188
  else
177
- if "$rvm_scripts_path"/match "$1" "^[0-9]" ; then
189
+ if "$rvm_scripts_path"/match "$next_token" "^[0-9]" ; then
178
190
  rvm_ruby_strings="${1//,/ }" ; shift
179
191
  unset rvm_ruby_interpreter
180
192
  else
181
- if [[ "ruby rbx jruby macruby ree rubinius maglev mput shyouhei ironruby" =~ $1 ]] ; then
182
- rvm_ruby_strings=$1
183
- rvm_ruby_interpreter=$1
193
+ if [[ "ruby rbx jruby macruby ree rubinius maglev mput shyouhei ironruby" =~ $next_token ]] ; then
194
+ rvm_ruby_strings=$next_token
195
+ rvm_ruby_interpreter=$next_token
184
196
  shift
185
197
  else
186
198
  unset rvm_ruby_interpreter rvm_ruby_strings
@@ -200,10 +212,10 @@ __rvm_parse_args() {
200
212
  ;;
201
213
 
202
214
  -v|--version)
203
- if [[ -z "$1" ]] ; then
215
+ if [[ -z "$next_token" ]] ; then
204
216
  rvm_action="version"
205
217
  else
206
- rvm_ruby_version="$1"
218
+ rvm_ruby_version="$next_token"
207
219
  shift
208
220
  fi
209
221
  ;;
@@ -213,7 +225,7 @@ __rvm_parse_args() {
213
225
  ;;
214
226
 
215
227
  --ree-options)
216
- if [[ ! -z "$1" ]] ; then
228
+ if [[ ! -z "$next_token" ]] ; then
217
229
  export rvm_ree_options="${1//,/ }" ; shift
218
230
  else
219
231
  rvm_action="error"
@@ -222,26 +234,26 @@ __rvm_parse_args() {
222
234
  ;;
223
235
 
224
236
  --patches|--patch)
225
- rvm_patch_names="$1 $rvm_patch_names"; shift
237
+ rvm_patch_names="$next_token ${rvm_patch_names:-""}"; shift
226
238
  rvm_patch_original_pwd="$PWD"
227
239
  ;;
228
240
 
229
241
  --head) rvm_head_flag=1 ;;
230
242
 
231
243
  --bin)
232
- if [[ "update" = "$rvm_action" ]] ; then
244
+ if [[ "update" = "${rvm_action:-""}" ]] ; then
233
245
  rvm_bin_flag=1
234
246
  else
235
- rvm_bin_path="$1" ; shift
247
+ rvm_bin_path="$next_token" ; shift
236
248
  fi
237
249
  ;;
238
250
 
239
251
  -r|--require)
240
- if [[ -z "$1" ]] ; then
252
+ if [[ -z "$next_token" ]] ; then
241
253
  rvm_action="error"
242
254
  rvm_error_message="-r|--require *must* be followed by a library name."
243
255
  else
244
- rvm_ruby_require="$rvm_ruby_require -r$1"
256
+ rvm_ruby_require="$rvm_ruby_require -r$next_token"
245
257
  shift
246
258
  fi
247
259
  ;;
@@ -253,7 +265,7 @@ __rvm_parse_args() {
253
265
 
254
266
  -f|--file)
255
267
  rvm_action="ruby"
256
- rvm_ruby_file="$1"
268
+ rvm_ruby_file="$next_token"
257
269
  shift
258
270
  ;;
259
271
 
@@ -275,7 +287,7 @@ __rvm_parse_args() {
275
287
  ;;
276
288
 
277
289
  --alias)
278
- if [[ -n "$1" ]]; then
290
+ if [[ -n "$next_token" ]]; then
279
291
  rvm_ruby_aliases="$(echo "${rvm_ruby_aliases//,/ } ${1//,/ }" | __rvm_strip)"
280
292
  shift
281
293
  fi
@@ -288,41 +300,59 @@ __rvm_parse_args() {
288
300
 
289
301
  wrapper)
290
302
  rvm_action="$rvm_token"
291
- rvm_ruby_string="$1" ;
292
- [[ -n "$1" ]] && shift
293
- rvm_wrapper_name="$1"
294
- [[ -n "$1" ]] && shift
303
+ rvm_ruby_string="$next_token" ;
304
+ [[ -n "$next_token" ]] && shift
305
+ rvm_wrapper_name="$next_token"
306
+ [[ -n "$next_token" ]] && shift
295
307
  rvm_ruby_args="$@" # list of binaries, or none
296
308
  rvm_parse_break=1
297
309
  ;;
298
310
 
299
- -G) path_variable="rvm_gems_path" ; __rvm_set_path_variable "$1"; shift ;;
300
- --source) path_variable="rvm_src_path" ; __rvm_set_path_variable "$1"; shift ;;
301
- --archives) path_variable="rvm_archives_path" ; __rvm_set_path_variable "$1"; shift ;;
311
+ -G) path_variable="rvm_gems_path" ; __rvm_set_path_variable "$next_token"; shift ;;
312
+ --source) path_variable="rvm_src_path" ; __rvm_set_path_variable "$next_token"; shift ;;
313
+ --archives) path_variable="rvm_archives_path" ; __rvm_set_path_variable "$next_token"; shift ;;
302
314
  -h|--help|usage) rvm_action=help ;;
303
- --make) rvm_ruby_make="$1" ; shift ;;
304
- --make-install) rvm_ruby_make_install="$1" ; shift ;;
305
- --nice) rvm_niceness="$1" ; shift ;;
306
- -l|--level) rvm_ruby_patch_level="p$1" ; shift ;;
307
- # TODO: handle this below better (if $1 is null)
308
- --sdk) rvm_sdk="$1" ; shift ;;
309
- --archflags) rvm_archflags="$1" ; shift ;;
315
+ --make) rvm_ruby_make="$next_token" ; shift ;;
316
+ --make-install) rvm_ruby_make_install="$next_token" ; shift ;;
317
+ --nice) rvm_niceness="$next_token" ; shift ;;
318
+ -l|--level) rvm_ruby_patch_level="p$next_token" ; shift ;;
319
+ # TODO: handle this below better (if $next_token is null)
320
+ --sdk) rvm_sdk="$next_token" ; shift ;;
321
+ --archflags) rvm_archflags="$next_token" ; shift ;;
310
322
  --install) rvm_install_on_use_flag=1 ;;
311
- --trace) rvm_trace_flag=1 ; set -x ;;
323
+ --trace)
324
+ rvm_trace_flag=1
325
+ if [[ -z "${ZSH_VERSION:-""}" ]] ; then
326
+ local option="" ;
327
+ for option in verbose xtrace errexit errtrace noclobber nounset pipefail ; do
328
+ set -o $option
329
+ done
330
+ export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
331
+ else
332
+ set -x
333
+ fi
334
+ ;;
335
+ --debug)
336
+ rvm_debug_flag=1
337
+ local option="" ;
338
+ for option in verbose errtrace ; do
339
+ set -o $option
340
+ done
341
+ ;;
312
342
  -q|--quiet) rvm_quiet_flag=1 ;;
313
343
  -s|--silent) rvm_silent_flag=1 ;;
314
- --proxy) rvm_proxy="$1" ; shift ;;
344
+ --proxy) rvm_proxy="$next_token" ; shift ;;
315
345
  --disable-llvm|--disable-jit) rvm_llvm_flag=0 ;;
316
346
  --enable-llvm|--enable-jit) rvm_llvm_flag=1 ;;
317
347
 
318
348
  reboot|damnit|wtf|argh|BOOM|boom|wth) $rvm_action="reboot" ;;
319
349
 
320
- --self|--gem|--rubygems|--reconfigure|--default|--debug|--force|--export|--summary|--latest|--yaml|--json|--archive|--shebang|--env|--path|--tail|--delete|--verbose|--import|--rvmrc|--sticky|--create|--gems|--docs)
350
+ --self|--gem|--rubygems|--reconfigure|--default|--force|--export|--summary|--latest|--yaml|--json|--archive|--shebang|--env|--path|--tail|--delete|--verbose|--import|--rvmrc|--sticky|--create|--gems|--docs)
321
351
  export "rvm_${rvm_token//-/}_flag"=1
322
352
  ;;
323
353
 
324
354
  --dump-environment)
325
- export rvm_dump_environment_flag="$1"; shift
355
+ export rvm_dump_environment_flag="$next_token"; shift
326
356
  ;;
327
357
 
328
358
  --clang)
@@ -332,8 +362,8 @@ __rvm_parse_args() {
332
362
  ;;
333
363
 
334
364
  -j)
335
- if [[ ! -z "$1" ]] ; then
336
- rvm_make_flags="$rvm_make_flags -j$1"
365
+ if [[ ! -z "$next_token" ]] ; then
366
+ rvm_make_flags="$rvm_make_flags -j$next_token"
337
367
  shift
338
368
  else
339
369
  rvm_action="error"
@@ -342,13 +372,13 @@ __rvm_parse_args() {
342
372
  ;;
343
373
 
344
374
  --with-rubies)
345
- rvm_ruby_strings="$1"
375
+ rvm_ruby_strings="$next_token"
346
376
  shift
347
377
  ;;
348
378
 
349
379
  -C|--configure)
350
- if [[ ! -z "$1" ]] ; then
351
- rvm_ruby_configure_flags="$(echo $1 | sed -e 's#,--# --#g')"
380
+ if [[ ! -z "$next_token" ]] ; then
381
+ rvm_ruby_configure_flags="$(echo $next_token | sed -e 's#,--# --#g')"
352
382
  shift
353
383
  else
354
384
  rvm_action="error"
@@ -362,11 +392,11 @@ __rvm_parse_args() {
362
392
  --disable-*) rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token" ;;
363
393
 
364
394
  -I|--include)
365
- if [[ -z "$1" ]] ; then
395
+ if [[ -z "$next_token" ]] ; then
366
396
  rvm_action="error"
367
397
  rvm_error_message="-I|--include *must* be followed by a path."
368
398
  else
369
- rvm_ruby_load_path="$rvm_ruby_load_path:$1"
399
+ rvm_ruby_load_path="$rvm_ruby_load_path:$next_token"
370
400
  shift
371
401
  fi
372
402
  ;;
@@ -379,6 +409,7 @@ __rvm_parse_args() {
379
409
  if "$rvm_scripts_path/match" "$rvm_token" "^.+${rvm_gemset_separator}.+$" ; then
380
410
  rvm_gemset_name="${rvm_token/*${rvm_gemset_separator}/}"
381
411
  rvm_ruby_string="${rvm_token/${rvm_gemset_separator}*/}"
412
+
382
413
  elif echo "$rvm_token" | \grep -q '.gems$' ; then
383
414
  rvm_file_name="${rvm_token/.gems/}.gems" # Account for possible .gems.gems
384
415
  # elif [[ ! -z "$(echo "$rvm_token" | awk '/\.gems$/')" ]] ; then
@@ -386,45 +417,53 @@ __rvm_parse_args() {
386
417
  rvm_gemset_name="${rvm_token/.gems/}"
387
418
  rvm_file_name="$rvm_gemset_name.gems"
388
419
  fi
420
+
389
421
  elif echo "$rvm_token" | \grep -q ',' ; then
390
422
  rvm_ruby_strings="$rvm_token"
391
- if [[ -z "$rvm_action" ]] ; then
423
+ if [[ -z "${rvm_action:-""}" ]] ; then
392
424
  rvm_action="ruby" # Not sure if we really want to do this but we'll try it out.
393
425
  fi
426
+
394
427
  elif "$rvm_scripts_path/match" "$rvm_token" "^${rvm_gemset_separator}" ; then
395
- rvm_action="use"
396
- rvm_gemset_name="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $2}')"
428
+ rvm_action="${rvm_action:-use}"
397
429
  rvm_gemset_name="${rvm_token/*${rvm_gemset_separator}/}"
398
- rvm_ruby_string="$(__rvm_environment_identifier | awk -F${rvm_gemset_separator} '{print $1}')"
430
+ rvm_ruby_string="${rvm_ruby_string:-""}"
399
431
  rvm_ruby_strings="${rvm_ruby_string}${rvm_gemset_separator}${rvm_gemset_name}"
432
+
400
433
  elif "$rvm_scripts_path/match" "$rvm_token" "^.+${rvm_gemset_separator}.+$" ; then
401
- rvm_gemset_name="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $2}')"
402
- rvm_ruby_string="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $1}')"
434
+ gemset_name="${rvm_token/*${rvm_gemset_separator}/}"
435
+ rvm_ruby_string="$rvm_token"
403
436
  rvm_ruby_strings="$rvm_token"
437
+
404
438
  elif "$rvm_scripts_path/match" "$rvm_token" "^.+\\+.+$" ; then
405
439
  rvm_ruby_alias="${rvm_token/*+/}"
406
440
  rvm_ruby_string="${rvm_token/+*/}"
407
441
  rvm_ruby_strings="$rvm_ruby_string"
442
+
408
443
  elif "$rvm_scripts_path/match" "$rvm_token" "-" ; then
409
444
  rvm_ruby_string="$rvm_token"
410
445
  rvm_ruby_strings="$rvm_token"
446
+
411
447
  elif "$rvm_scripts_path/match" "$rvm_token" "^[0-9].[0-9]" ; then
412
448
  rvm_ruby_string="$rvm_token"
413
449
  rvm_ruby_strings="$rvm_token"
414
450
  rvm_action="${rvm_action:-use}"
451
+
415
452
  elif "$rvm_scripts_path/match" "$rvm_token" "^ree-" ; then
416
453
  rvm_ruby_string="$rvm_token"
417
454
  rvm_ruby_strings="$rvm_token"
418
455
  rvm_action="${rvm_action:-use}"
456
+
419
457
  elif [[ -L "$rvm_rubies_path/$rvm_token" ]] ; then # Alias
420
458
  rvm_ruby_string=$rvm_token
421
459
  rvm_ruby_strings="$rvm_token"
422
460
  rvm_action="${rvm_action:-use}"
461
+
423
462
  else
424
463
  if "$rvm_scripts_path/match" "$rvm_token" ".rb$" ; then # we have a specified ruby script
425
464
  rvm_ruby_args=$rvm_token
426
465
  rvm_ruby_file=$rvm_token
427
- if [[ -z "$rvm_action" ]] ; then rvm_action="ruby" ; fi
466
+ if [[ -z "${rvm_action:-""}" ]] ; then rvm_action="ruby" ; fi
428
467
  else
429
468
  rvm_action="error"
430
469
  rvm_error_message="Unrecognized command line argument: '$rvm_token'"
@@ -434,34 +473,47 @@ __rvm_parse_args() {
434
473
  rvm_action="error"
435
474
  rvm_error_message="Unrecognized command line argument(s): '$rvm_token $@'"
436
475
  fi
437
- if [[ "error" = "$rvm_action" ]] ; then
476
+
477
+ if [[ "error" = "${rvm_action:-""}" ]] ; then
438
478
  break;
439
479
  fi
440
480
  esac
441
481
 
442
- if [[ -z "$rvm_action" ]] && [[ ! -z "$rvm_ruby_string" ]] ; then rvm_action="use" ; fi
443
- if [[ ! -z "$rvm_parse_break" ]] || [[ ! -z "$rvm_error_message" ]] ; then unset rvm_parse_break; break; fi
482
+ if [[ -z "${rvm_action:-""}" && -n "${rvm_ruby_string:-""}" ]] ; then rvm_action="use" ; fi
483
+
484
+ if [[ ${rvm_parse_break:-0} -eq 1 || -n "${rvm_error_message:-""}" ]] ; then break ; fi
444
485
  done
445
486
 
487
+ # Empty args list.
446
488
  while [[ $# -gt 0 ]] ; do shift ; done
447
489
 
448
- if [[ ! -z "$rvm_error_message" ]] ; then __rvm_pushpop ; return 1 ; fi
490
+ if [[ -n "${rvm_error_message:-""}" ]] ; then
491
+ __rvm_pushpop
492
+ "$rvm_scripts_path"/log "fail" "$rvm_error_message ( see: 'rvm usage' )"
493
+ return 1
494
+ fi
495
+
449
496
  }
450
497
 
451
498
  rvm() {
499
+ local next_token
500
+
452
501
  __rvm_setup
453
502
 
454
- case $- in *i*) rvm_interactive=1 ;;
455
- *) unset rvm_interactive ;;
456
- esac ; export rvm_interactive
503
+ case $- in *i*) rvm_interactive_flag=1 ;;
504
+ *) rvm_interactive_flag=0 ;;
505
+ esac ; export rvm_interactive_flag
457
506
 
458
- if [[ -z "$ZSH_VERSION" ]] ; then
507
+ if [[ -z "${ZSH_VERSION:-""}" ]] ; then
459
508
  trap '\rm -rf "$rvm_tmp_path/$$" >/dev/null 2>&1' 0 1 2 3 15
460
509
  fi
461
510
 
462
511
  # Check that this is the current version.
463
512
  disk_version=$(tail -n 3 < "${rvm_path:-$HOME/.rvm}/lib/VERSION.yml" | sed -e 's/^.*: //g' | \tr "\n" '.' | sed -e 's/\.$//')
464
- if [[ "${rvm_version}" != "${disk_version}" ]] && [[ "reload" != "$1" ]]; then
513
+
514
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; else next_token="" ; fi
515
+
516
+ if [[ "${rvm_version}" != "${disk_version}" ]] && [[ "reload" != "$next_token" ]]; then
465
517
  printf "\nA RVM version ${disk_version} is installed yet ${rvm_version} is loaded.\n Please do one of the following:\n * 'rvm reload'\n * open a new shell\n * source your shell init scripts"
466
518
  return 1
467
519
  fi
@@ -471,7 +523,12 @@ rvm() {
471
523
  __rvm_initialize
472
524
  __rvm_parse_args "$@"
473
525
 
474
- export BUNDLE_PATH GEM_HOME GEM_PATH rvm_ruby_string rvm_action rvm_bin_flag rvm_debug_flag rvm_delete_flag rvm_docs_type rvm_file_name rvm_gemset_name rvm_head_flag rvm_install_on_use_flag rvm_interactive rvm_llvm_flag rvm_make_flags rvm_proxy rvm_remove_flag rvm_ruby_args rvm_ruby_configure_flags rvm_ruby_file rvm_ruby_gem_home rvm_ruby_interpreter rvm_ruby_name rvm_ruby_version rvm_system_flag rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_patch_names rvm_patch_original_pwd rvm_clang_flag rvm_install_arguments
526
+ rvm_reload_flag=${rvm_reload_flag:-0}
527
+ rvm_use_flag=${rvm_reload_flag:-0}
528
+ rvm_delete_flag=${rvm_delete_flag:-0}
529
+ rvm_action="${rvm_action:-usage}"
530
+
531
+ export BUNDLE_PATH GEM_HOME GEM_PATH rvm_ruby_string rvm_action rvm_bin_flag rvm_debug_flag rvm_delete_flag rvm_docs_type rvm_file_name rvm_gemset_name rvm_head_flag rvm_install_on_use_flag rvm_interactive_flag rvm_llvm_flag rvm_make_flags rvm_proxy rvm_remove_flag rvm_ruby_args rvm_ruby_configure_flags rvm_ruby_file rvm_ruby_gem_home rvm_ruby_interpreter rvm_ruby_name rvm_ruby_version rvm_system_flag rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_patch_names rvm_patch_original_pwd rvm_clang_flag rvm_install_arguments
475
532
  export rvm_path rvm_rubies_path rvm_scripts_path rvm_archives_path rvm_src_path rvm_patches_path rvm_patches_path rvm_patchsets_path rvm_log_path rvm_bin_path rvm_gems_path rvm_config_path rvm_tmp_path rvm_hooks_path rvm_gems_cache_path rvm_gemset_separator rvm_ruby_aliases rvm_quiet_flag rvm_silent_flag
476
533
 
477
534
  result=0
@@ -491,16 +548,13 @@ rvm() {
491
548
 
492
549
  list) "$rvm_scripts_path"/list $rvm_ruby_args ; result=$? ;;
493
550
  # TODO: Make debug run in the current environment.
494
- debug) "$rvm_scripts_path"/info '' debug ; result=$? ;;
495
- help) "$rvm_scripts_path"/help $rvm_ruby_args ; result=$? ;;
496
- env) "$rvm_scripts_path"/env "$rvm_ruby_string" ; result=$? ;;
551
+ debug) "$rvm_scripts_path/info" '' debug ; result=$? ;;
552
+ help) "$rvm_scripts_path/help" $rvm_ruby_args ; result=$? ;;
553
+ env) "$rvm_scripts_path/env" "$rvm_ruby_string" ; result=$? ;;
497
554
  info)
498
- if [[ "$1" = "info" ]]; then shift; fi
499
- if [[ -z "$rvm_ruby_args" ]] ; then
500
- "$rvm_scripts_path/info"
501
- else
502
- "$rvm_scripts_path/info" $rvm_ruby_args
503
- fi
555
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; else next_token="" ; fi
556
+ if [[ "$next_token" = "info" ]]; then shift; fi
557
+ "$rvm_scripts_path/info" $rvm_ruby_args
504
558
  result=$?
505
559
  ;;
506
560
 
@@ -531,7 +585,7 @@ rvm() {
531
585
  __rvm_run_script "$rvm_action" ; result=$?
532
586
  ;;
533
587
 
534
- rvmrc) eval "__rvm_rvmrc_tools $rvm_ruby_args" ; result="$?" ;;
588
+ rvmrc) eval "__rvm_rvmrc_tools $rvm_ruby_args" ; result=$? ;;
535
589
 
536
590
  gemset)
537
591
  #if "$rvm_scripts_path/match" $rvm_ruby_args use ; then
@@ -542,11 +596,11 @@ rvm() {
542
596
  fi
543
597
  else
544
598
  export rvm_ruby_strings
545
- "$rvm_scripts_path"/gemsets $rvm_ruby_args
546
- unset rvm_ruby_strings
599
+ "$rvm_scripts_path/gemsets" $rvm_ruby_args ; result=$?
600
+ rvm_ruby_strings=""
547
601
 
548
602
  # Clear the gemset.
549
- if [[ "$rvm_delete_flag" -eq 1 ]] ; then
603
+ if [[ $rvm_delete_flag -eq 1 ]] ; then
550
604
  gem_prefix="$(echo $GEM_HOME | sed 's/'${rvm_gemset_separator}'.*$//')"
551
605
  if [[ "$GEM_HOME" = "${gem_prefix}${rvm_gemset_separator}${rvm_gemset_name}" ]] ; then
552
606
  rvm_ruby_gem_home="$gem_prefix"
@@ -565,10 +619,10 @@ rvm() {
565
619
  "$rvm_scripts_path"/monitor ; result=$?
566
620
  ;;
567
621
 
568
- notes) "$rvm_scripts_path"/notes ; result=$? ;;
569
- reload) unset rvm_loaded_flag ; rvm_reload_flag=1 ;;
622
+ notes) "$rvm_scripts_path/notes" ; result=$? ;;
623
+ reload) rvm_loaded_flag=0 ; rvm_reload_flag=1 ;;
570
624
  tests|specs) rvm_action="rake" ; __rvm_do ; result=$? ;;
571
- package) "$rvm_scripts_path"/package $rvm_ruby_args ; result=$? ;;
625
+ package) "$rvm_scripts_path/package" $rvm_ruby_args ; result=$? ;;
572
626
 
573
627
  fetch|install|uninstall|remove)
574
628
  if [[ -n "$rvm_ruby_strings" ]]; then
@@ -580,13 +634,12 @@ rvm() {
580
634
  ;;
581
635
 
582
636
  error)
583
- "$rvm_scripts_path"/log "fail" "$rvm_error_message ( see: 'rvm usage' )"
584
637
  __rvm_pushpop
585
638
  result=1
586
639
  ;;
587
640
 
588
641
  *)
589
- if [[ ! -z "$rvm_action" ]] ; then
642
+ if [[ -n "${rvm_action:-""}" ]] ; then
590
643
  "$rvm_scripts_path/log" "fail" "unknown action '$rvm_action'"
591
644
  else
592
645
  __rvm_usage
@@ -600,10 +653,13 @@ rvm() {
600
653
  __rvm_project_rvmrc
601
654
  fi
602
655
 
603
- if [[ ! -z "$rvm_trace_flag" ]] ; then set +x ; unset rvm_trace_flag ; fi
604
-
605
656
  __rvm_teardown
606
657
 
658
+ if [[ $rvm_trace_flag -eq 1 ]] ; then
659
+ set +x
660
+ rvm_trace_flag=0
661
+ fi
662
+
607
663
  return $result
608
664
  }
609
665