rvm 1.0.4 → 1.0.5

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.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 0
4
- :patch: 4
4
+ :patch: 5
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rvm}
8
- s.version = "1.0.4"
8
+ s.version = "1.0.5"
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-06}
12
+ s.date = %q{2010-09-07}
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}
@@ -108,6 +108,7 @@ Gem::Specification.new do |s|
108
108
  "scripts/color",
109
109
  "scripts/completion",
110
110
  "scripts/db",
111
+ "scripts/default",
111
112
  "scripts/disk-usage",
112
113
  "scripts/docs",
113
114
  "scripts/env",
@@ -4,6 +4,23 @@ unset rvm_default_flag rvm_wrapper_name
4
4
 
5
5
  source "$rvm_scripts_path"/base
6
6
 
7
+ usage() {
8
+ printf "
9
+
10
+ Usage:
11
+
12
+ rvm alias [action] [arguments]
13
+
14
+ Examples:
15
+
16
+ rvm alias create [alias_name] [ruby]
17
+ rvm alias delete [alias_name]
18
+ rvm alias show [alias_name]
19
+ rvm alias list
20
+
21
+ "
22
+ }
23
+
7
24
  alias_conflicts_with_ruby() {
8
25
  # If default exists, we should return true.
9
26
  [[ "$1" == "default" && ! -L "$rvm_rubies_path/default" ]] && return 1
@@ -15,44 +32,48 @@ alias_conflicts_with_ruby() {
15
32
  __rvm_ruby_string > /dev/null 2>&1
16
33
  echo "$?"
17
34
  )"
35
+
18
36
  if [[ "0" == "$alias_check_result" ]]; then
19
- "$rvm_scripts_path"/log "error" "You are attempted to create an alias called '$1', which is recognized as a rvm ruby."
37
+ "$rvm_scripts_path"/log "error" "\nYou have attempted to create an alias called '$1', which is recognized as a rvm ruby.\n"
20
38
  return 0
21
39
  fi
40
+
22
41
  return 1
42
+
23
43
  unset alias_check_result
24
44
  }
25
45
 
26
- show_alias() {
46
+ alias_show() {
27
47
  if [[ -z "$alias_name" ]]; then
28
- "$rvm_scripts_path"/log "error" "usage: 'rvm alias show [alias_name]'"
48
+ "$rvm_scripts_path"/log "error" "\nusage: 'rvm alias show [alias_name]'\n"
29
49
  result=1
30
50
  return
31
51
  fi
32
52
  expanded_alias_name="$("$rvm_scripts_path"/db "$rvm_config_path/alias" "$alias_name")"
33
53
  if [[ -z "$expanded_alias_name" ]]; then
34
- "$rvm_scripts_path"/log "error" "Unknown alias name: '$alias_name'"
54
+ "$rvm_scripts_path"/log "error" "\nUnknown alias name: '$alias_name'\n"
35
55
  result=1
36
56
  else
37
57
  result=0
38
58
  if [[ -n "$gemset_name" ]] ; then
39
- printf "${expanded_alias_name}${rvm_gemset_separator}${gemset_name}"
59
+ printf "${expanded_alias_name}${rvm_gemset_separator}${gemset_name}\n"
40
60
  else
41
- printf "$expanded_alias_name"
61
+ printf "$expanded_alias_name\n"
42
62
  fi
43
63
  fi
44
64
  unset expanded_alias_name
45
65
  }
46
66
 
47
- delete_alias() {
67
+ alias_delete() {
48
68
  echo "Deleting alias: $alias_name"
69
+
49
70
  for link in "$rvm_rubies_path/$alias_name" ; do
50
71
  if [[ -L "$link" ]] ; then rm -f $link ; fi
51
72
  done
52
73
  "$rvm_scripts_path"/db "$rvm_config_path/alias" "$alias_name" "delete"
53
74
  }
54
75
 
55
- create_alias() {
76
+ alias_create() {
56
77
  rvm_environment_identifier="${rvm_environment_identifier:-""}"
57
78
  alias_name="${alias_name:-""}"
58
79
  rvm_ruby_string="${rvm_ruby_string:-""}"
@@ -63,7 +84,7 @@ create_alias() {
63
84
  fi
64
85
 
65
86
  if [[ -z "$rvm_environment_identifier" ]] || [[ -z "$alias_name" ]] ; then
66
- "$rvm_scripts_path"/log "error" "usage: 'rvm alias [alias_name] [ruby_string]'"
87
+ "$rvm_scripts_path"/log "error" "\nusage: 'rvm alias [alias_name] [ruby_string]'\n"
67
88
  result=1
68
89
  else
69
90
  if [[ -z "$rvm_alias" ]] ; then
@@ -76,7 +97,7 @@ create_alias() {
76
97
  rvm_ruby_string="$rvm_environment_identifier"
77
98
  fi
78
99
  if [[ -z "$rvm_ruby_string" ]]; then
79
- "$rvm_scripts_path"/log "error" "unknown ruby string specified"
100
+ "$rvm_scripts_path"/log "error" "\nUnknown ruby string '$rvm_ruby_string' specified\n"
80
101
  result=1
81
102
  return
82
103
  fi
@@ -87,10 +108,10 @@ create_alias() {
87
108
  "$rvm_scripts_path"/db "$rvm_config_path/alias" "$alias_name" "$final_environment_identifier"
88
109
  else
89
110
  if [[ -d "$rvm_rubies_path/$alias_name" ]] ; then
90
- "$rvm_scripts_path"/log "error" "$rvm_rubies_path/$alias_name is taken and is *not* able to be an alias name."
111
+ "$rvm_scripts_path"/log "error" "\n$rvm_rubies_path/$alias_name is taken and is *not* able to be an alias name.\n"
91
112
  result=1
92
113
  else
93
- "$rvm_scripts_path"/log "error" "$rvm_rubies_path/$alias_name is already aliased."
114
+ "$rvm_scripts_path"/log "error" "\n$rvm_rubies_path/$alias_name is already aliased.\n"
94
115
  result=1
95
116
  fi
96
117
  fi
@@ -106,37 +127,38 @@ alias_list() {
106
127
  }
107
128
 
108
129
  args=($*)
109
- action="${args[0]}"
110
- alias_name="${args[1]}"
111
- rvm_environment_identifier="${args[2]}"
130
+ action="${args[0]:-""}"
131
+ alias_name="${args[1]:-""}"
132
+ rvm_environment_identifier="${args[2]:-""}"
112
133
  args="$(echo ${args[@]:3}) " # Strip trailing / leading / extra spacing.
134
+ result=0
113
135
 
114
136
  if [[ ! -f "$rvm_config_path/alias" ]] ; then touch "$rvm_config_path/alias" ; fi
137
+
115
138
  if printf "$alias_name" | grep -q "$rvm_gemset_separator" ; then
116
139
  gemset_name="${alias_name/*${rvm_gemset_separator}/}"
117
140
  alias_name="${alias_name/${rvm_gemset_separator}*/}"
141
+ else
142
+ gemset_name=""
118
143
  fi
144
+
119
145
  if [[ ! -z "$alias_name" ]] ; then
120
146
  rvm_alias="$("$rvm_scripts_path"/db "$rvm_config_path/alias" "$alias_name")"
121
147
  fi
122
148
 
123
- # CLI API:
124
- # rvm alias create [alias_name] [ruby]
125
- # rvm alias delete [alias_name]
126
- # rvm alias show [alias_name]
127
- # rvm alias list
128
149
  if [[ "$action" = "delete" ]] ; then
129
- delete_alias
150
+ alias_delete
130
151
  elif [[ "$action" = "create" ]] ; then
131
- create_alias
152
+ alias_create
132
153
  elif [[ "$action" = "list" ]] ; then
133
154
  alias_list
134
155
  elif [[ "$action" = "show" ]]; then
135
- show_alias
156
+ alias_show
157
+ elif [[ "$action" = "help" ]]; then
158
+ usage
136
159
  else
137
- "$rvm_scripts_path"/log "error" "usage: 'rvm alias [action] [arguments]"
160
+ usage
161
+ exit 1
138
162
  fi
139
163
 
140
- unset action alias_name rvm_ruby_string rvm_environment_identifier final_environment_identifier
141
-
142
- exit $result
164
+ exit $?
@@ -1,14 +1,29 @@
1
+ #!/usr/bin/env bash
2
+
1
3
  # Base is a collection general files + commonely included
2
4
  # setup functions.
3
5
 
4
6
  # Load the general scripts.
5
7
  # Use rvm_base_except="" to override the except.
6
- for script_name in initialize utility selector; do
7
- if echo "$rvm_base_except" | \grep -vq "$script_name" ; then
8
+ for script_name in initialize utility selector ; do
9
+ if echo "${rvm_base_except:-""}" | \grep -vq "$script_name" ; then
8
10
  source "$rvm_scripts_path"/$script_name
9
11
  fi
10
- done; unset script_name rvm_base_except
12
+ done ; unset script_name rvm_base_except
13
+
14
+ #for option in errexit noclobber nounset ; do
15
+ # set -o $option
16
+ #done
17
+
18
+ #if [[ -z "${ZSH_VERSION:-""}" ]] ; then
19
+ # set -o errtrace
20
+ # set -o pipefail
21
+ #fi
22
+
23
+ if [[ ${rvm_trace_flag:-0} -gt 0 ]]; then
24
+ export rvm_trace_flag=1
25
+ set -o xtrace
26
+ fi
11
27
 
12
- # Setup hooks etc.
13
- __rvm_inherit_trace_flag
14
- __rvm_cleanup_temp_on_exit
28
+ # Cleanup tmp on exit.
29
+ trap "__rvm_cleanup_temp_for '$$'" 0 1 2 3 15
@@ -22,10 +22,9 @@ __rvm_parse_args() {
22
22
  local rvm_parse_break=0
23
23
  local rvm_error_message=""
24
24
 
25
- while [[ $# -gt 0 ]] ; do
26
- rvm_token="$next_token" ; shift
27
-
28
- if [[ $# -gt 0 ]] ; then next_token="$1" ; else next_token="" ; fi
25
+ while [[ -n "$next_token" ]] ; do
26
+ rvm_token="$next_token"
27
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
29
28
 
30
29
  case "$rvm_token" in
31
30
  fetch|version|srcdir|reset|debug|reload|update|monitor|notes|implode|seppuku|question|answer|env)
@@ -37,14 +36,16 @@ __rvm_parse_args() {
37
36
  if [[ "$next_token" = "--only-path" ]]; then
38
37
  shift; rvm_only_path_flag=1
39
38
  fi
40
- rvm_ruby_args="$*"
39
+ rvm_ruby_args="$next_token $*"
41
40
  rvm_parse_break=1
42
41
  ;;
43
42
 
44
43
  use)
45
44
  rvm_action="$rvm_token"
46
45
  rvm_verbose_flag=1
47
- if [[ "ruby" = "$next_token" ]] ; then shift ; fi
46
+ if [[ "ruby" = "$next_token" ]] ; then
47
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
48
+ fi
48
49
  ;;
49
50
 
50
51
  install|uninstall)
@@ -65,7 +66,14 @@ __rvm_parse_args() {
65
66
  rvm_ruby_string="$rvm_token"
66
67
  rvm_ruby_strings="$rvm_token"
67
68
  rvm_action="${rvm_action:-use}"
68
- if "$rvm_scripts_path"/match "$next_token" "^[0-9]\.[0-9]" ; then rvm_ruby_version=$next_token ; shift ; fi
69
+ if "$rvm_scripts_path"/match "$next_token" "^[0-9]\.[0-9]" ; then
70
+ rvm_ruby_version=$next_token
71
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
72
+ fi
73
+ ;;
74
+
75
+ default)
76
+
69
77
  ;;
70
78
 
71
79
  gemset)
@@ -82,11 +90,11 @@ __rvm_parse_args() {
82
90
 
83
91
  elif [[ "use" = "$next_token" ]] ; then
84
92
  rvm_use_flag=1
85
- rvm_ruby_args="$@"
93
+ rvm_ruby_args="$next_token $@"
86
94
  rvm_gemset_name="$next_token"
87
- shift # Clear next_token
95
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
88
96
 
89
- if [[ $# -gt 0 ]] ; then rvm_gemset_name="$1" ; else rvm_gemset_name="" ; fi
97
+ if [[ -n "$next_token" ]] ; then rvm_gemset_name="$next_token" ; else rvm_gemset_name="" ; fi
90
98
 
91
99
  if echo $rvm_gemset_name | \grep -q $rvm_gemset_separator ; then
92
100
  rvm_ruby_string=$(echo $rvm_gemset_name | sed -e 's/\(.*\)'${rvm_gemset_separator}'.*/\1/')
@@ -101,8 +109,11 @@ __rvm_parse_args() {
101
109
 
102
110
  elif [[ "delete" = "$next_token" ]] ; then
103
111
  rvm_delete_flag=1
104
- rvm_ruby_args="$@" ; shift
105
- rvm_gemset_name="$next_token"; shift
112
+ rvm_ruby_args="$next_token $@"
113
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
114
+ rvm_gemset_name="$next_token"
115
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
116
+
106
117
  if echo "$rvm_gemset_name" | \grep -q "$rvm_gemset_separator" ; then
107
118
  rvm_ruby_string=$(echo "$rvm_gemset_name" | sed 's/\(.*\)'${rvm_gemset_separator}'.*/\1/')
108
119
  rvm_gemset_name=$(echo "$rvm_gemset_name" | sed 's/.*'${rvm_gemset_separator}'\(.*\)/\1/')
@@ -115,51 +126,60 @@ __rvm_parse_args() {
115
126
  else
116
127
  rvm_gemset_name="${rvm_gemset_name:-""}"
117
128
  if [[ "$rvm_ruby_string" != "$rvm_gemset_name" ]] ; then __rvm_ruby_string ; fi
118
- rvm_ruby_args="$@"
129
+ rvm_ruby_args="$next_token $@"
119
130
  fi
131
+
120
132
  rvm_parse_break=1
121
133
  ;;
122
134
 
123
135
  gemdir|gempath|gemhome)
124
136
  rvm_action=$rvm_token
125
137
  rvm_gemdir_flag=1
126
- if [[ "system" = "$next_token" ]] ; then rvm_system_flag=1 ; shift ; fi
127
- if [[ "user" = "$next_token" ]] ; then rvm_user_flag=1 ; shift ; fi
138
+
139
+ if [[ "system" = "$next_token" ]] ; then
140
+ rvm_system_flag=1
141
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
142
+ fi
143
+
144
+ if [[ "user" = "$next_token" ]] ; then
145
+ rvm_user_flag=1
146
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
147
+ fi
128
148
  ;;
129
149
 
130
150
  inspect|list|info|strings)
131
151
  rvm_action="$rvm_token"
132
- rvm_ruby_args="$@"
152
+ rvm_ruby_args="$next_token $@"
133
153
  rvm_parse_break=1
134
154
  ;;
135
155
 
136
156
  -S)
137
157
  rvm_action="ruby"
138
- rvm_ruby_args="$rvm_token $(__rvm_quote_args "$@")"
158
+ rvm_ruby_args="$rvm_token $next_token $(__rvm_quote_args "$@")"
139
159
  rvm_parse_break=1
140
160
  ;;
141
161
 
142
162
  -e)
143
163
  rvm_action="ruby"
144
- rvm_ruby_args="$rvm_token $(__rvm_quote_args "$@")"
164
+ rvm_ruby_args="$rvm_token $next_token $(__rvm_quote_args "$@")"
145
165
  rvm_parse_break=1
146
166
  ;;
147
167
 
148
168
  docs|alias|rubygems|exec|cleanup|tools|disk-usage|snapshot|repair|migrate|upgrade)
149
169
  rvm_action="$rvm_token"
150
- rvm_ruby_args="$(__rvm_quote_args "$@")"
170
+ rvm_ruby_args="$next_token $(__rvm_quote_args "$@")"
151
171
  rvm_parse_break=1
152
172
  ;;
153
173
 
154
174
  load-rvmrc)
155
175
  rvm_action="rvmrc"
156
- rvm_ruby_args="'load' $(__rvm_quote_args "$@")"
176
+ rvm_ruby_args="'load' $next_token $(__rvm_quote_args "$@")"
157
177
  rvm_parse_break=1
158
178
  ;;
159
179
 
160
180
  rvmrc)
161
181
  rvm_action="rvmrc"
162
- rvm_ruby_args="$(__rvm_quote_args "$@")"
182
+ rvm_ruby_args="$next_token $(__rvm_quote_args "$@")"
163
183
  rvm_parse_break=1
164
184
  ;;
165
185
 
@@ -187,16 +207,16 @@ __rvm_parse_args() {
187
207
 
188
208
  elif [[ "-S" = "$next_token" ]] ; then
189
209
  rvm_action="ruby"
190
- rvm_ruby_args="$flag $(__rvm_quote_args "$@")"
210
+ rvm_ruby_args="$flag $next_token $(__rvm_quote_args "$@")"
191
211
  rvm_parse_break=1
192
212
 
193
213
  elif [[ "-e" = "$next_token" ]] ; then
194
214
  rvm_action="ruby"
195
- rvm_ruby_args="$flag $(__rvm_quote_args "$@")"
215
+ rvm_ruby_args="$flag $next_token $(__rvm_quote_args "$@")"
196
216
  rvm_parse_break=1
197
217
 
198
218
  else
199
- rvm_ruby_args="$(__rvm_quote_args "$@")"
219
+ rvm_ruby_args="$next_token $@"
200
220
  rvm_parse_break=1
201
221
  fi
202
222
  else
@@ -205,14 +225,15 @@ __rvm_parse_args() {
205
225
 
206
226
  else
207
227
  if "$rvm_scripts_path"/match "$next_token" "^[0-9]" ; then
208
- rvm_ruby_strings="${1//,/ }" ; shift
228
+ rvm_ruby_strings="${1//,/ }"
229
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
209
230
  unset rvm_ruby_interpreter
210
231
 
211
232
  else
212
233
  if [[ "ruby rbx jruby macruby ree rubinius maglev mput shyouhei ironruby" =~ $next_token ]] ; then
213
234
  rvm_ruby_strings=$next_token
214
235
  rvm_ruby_interpreter=$next_token
215
- shift
236
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
216
237
  else
217
238
  unset rvm_ruby_interpreter rvm_ruby_strings
218
239
  fi
@@ -227,7 +248,7 @@ __rvm_parse_args() {
227
248
 
228
249
  specs|tests)
229
250
  rvm_action="rake"
230
- rvm_ruby_args="$(echo $rvm_token | sed -e 's/s$//')"
251
+ rvm_ruby_args="$(echo "$rvm_token" | sed -e 's/s$//')"
231
252
  ;;
232
253
 
233
254
  -v|--version)
@@ -235,7 +256,7 @@ __rvm_parse_args() {
235
256
  rvm_action="version"
236
257
  else
237
258
  rvm_ruby_version="$next_token"
238
- shift
259
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
239
260
  fi
240
261
  ;;
241
262
 
@@ -245,7 +266,9 @@ __rvm_parse_args() {
245
266
 
246
267
  --ree-options)
247
268
  if [[ ! -z "$next_token" ]] ; then
248
- export rvm_ree_options="${1//,/ }" ; shift
269
+ export rvm_ree_options="${1//,/ }"
270
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
271
+
249
272
  else
250
273
  rvm_action="error"
251
274
  rvm_error_message="--ree-options *must* be followed by... well... options."
@@ -253,7 +276,8 @@ __rvm_parse_args() {
253
276
  ;;
254
277
 
255
278
  --patches|--patch)
256
- rvm_patch_names="$next_token ${rvm_patch_names:-""}"; shift
279
+ rvm_patch_names="$next_token ${rvm_patch_names:-""}"
280
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
257
281
  rvm_patch_original_pwd="$PWD"
258
282
  ;;
259
283
 
@@ -263,7 +287,8 @@ __rvm_parse_args() {
263
287
  if [[ "update" = "${rvm_action:-""}" ]] ; then
264
288
  rvm_bin_flag=1
265
289
  else
266
- rvm_bin_path="$next_token" ; shift
290
+ rvm_bin_path="$next_token"
291
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
267
292
  fi
268
293
  ;;
269
294
 
@@ -273,7 +298,7 @@ __rvm_parse_args() {
273
298
  rvm_error_message="-r|--require *must* be followed by a library name."
274
299
  else
275
300
  rvm_ruby_require="$rvm_ruby_require -r$next_token"
276
- shift
301
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
277
302
  fi
278
303
  ;;
279
304
 
@@ -285,7 +310,7 @@ __rvm_parse_args() {
285
310
  -f|--file)
286
311
  rvm_action="ruby"
287
312
  rvm_ruby_file="$next_token"
288
- shift
313
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
289
314
  ;;
290
315
 
291
316
  system|default)
@@ -297,7 +322,7 @@ __rvm_parse_args() {
297
322
 
298
323
  help)
299
324
  rvm_action="$rvm_token"
300
- rvm_ruby_args="$@"
325
+ rvm_ruby_args="$next_token $@"
301
326
  rvm_parse_break=1
302
327
  ;;
303
328
 
@@ -308,59 +333,110 @@ __rvm_parse_args() {
308
333
  --alias)
309
334
  if [[ -n "$next_token" ]]; then
310
335
  rvm_ruby_aliases="$(echo "${rvm_ruby_aliases//,/ } ${1//,/ }" | __rvm_strip)"
311
- shift
336
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
312
337
  fi
313
338
  ;;
314
339
 
315
340
  --symlink)
316
341
  "$rvm_scripts_path/log" "warn" "--symlink has been removed, please see 'rvm wrapper'."
317
- shift
342
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
318
343
  ;;
319
344
 
320
345
  wrapper)
321
346
  rvm_action="$rvm_token"
322
347
  rvm_ruby_string="$next_token" ;
323
- [[ -n "$next_token" ]] && shift
348
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
324
349
  rvm_wrapper_name="$next_token"
325
- [[ -n "$next_token" ]] && shift
326
- rvm_ruby_args="$@" # list of binaries, or none
350
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
351
+ rvm_ruby_args="$next_token $@" # list of binaries, or none
327
352
  rvm_parse_break=1
328
353
  ;;
329
354
 
330
- -G) path_variable="rvm_gems_path" ; __rvm_set_path_variable "$next_token"; shift ;;
331
- --source) path_variable="rvm_src_path" ; __rvm_set_path_variable "$next_token"; shift ;;
332
- --archives) path_variable="rvm_archives_path" ; __rvm_set_path_variable "$next_token"; shift ;;
333
- -h|--help|usage) rvm_action=help ;;
334
- --make) rvm_ruby_make="$next_token" ; shift ;;
335
- --make-install) rvm_ruby_make_install="$next_token" ; shift ;;
336
- --nice) rvm_niceness="$next_token" ; shift ;;
337
- -l|--level) rvm_ruby_patch_level="p$next_token" ; shift ;;
338
- # TODO: handle this below better (if $next_token is null)
339
- --sdk) rvm_sdk="$next_token" ; shift ;;
340
- --archflags) rvm_archflags="$next_token" ; shift ;;
341
- --install) rvm_install_on_use_flag=1 ;;
342
- --trace)
355
+ -G)
356
+ path_variable="rvm_gems_path"
357
+ __rvm_set_path_variable "$next_token"
358
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
359
+ ;;
360
+
361
+ --source)
362
+ path_variable="rvm_src_path"
363
+ __rvm_set_path_variable "$next_token"
364
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
365
+ ;;
366
+
367
+ --archives)
368
+ path_variable="rvm_archives_path"
369
+ __rvm_set_path_variable "$next_token"
370
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
371
+ ;;
372
+
373
+ -h|--help|usage)
374
+ rvm_action=help
375
+ ;;
376
+
377
+ --make)
378
+ rvm_ruby_make="$next_token"
379
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
380
+ ;;
381
+ --make-install)
382
+ rvm_ruby_make_install="$next_token" ; shift
383
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
384
+ ;;
385
+
386
+ --nice)
387
+ rvm_niceness="$next_token"
388
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
389
+ ;;
390
+
391
+ -l|--level)
392
+ rvm_ruby_patch_level="p$next_token"
393
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
394
+ ;;
395
+
396
+ --sdk)
397
+ rvm_sdk="$next_token"
398
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
399
+ ;;
400
+
401
+ --archflags)
402
+ rvm_archflags="$next_token"
403
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
404
+ ;;
405
+
406
+ --install)
407
+ rvm_install_on_use_flag=1
408
+ ;;
409
+
410
+ --trace|--debug)
411
+ local option=""
412
+ rvm_debug_flag=1
413
+
414
+ for option in verbose errexit noclobber nounset ; do
415
+ set -o $option
416
+ done
417
+ if [[ -z "${ZSH_VERSION:-""}" ]] ; then
418
+ set -o errtrace
419
+ set -o pipefail
420
+ fi
421
+
422
+ if [[ "$rvm_token" = "--trace" ]] ; then
343
423
  rvm_trace_flag=1
424
+ set -o xtrace
344
425
  if [[ -z "${ZSH_VERSION:-""}" ]] ; then
345
- local option="" ;
346
- for option in verbose xtrace errexit errtrace noclobber nounset pipefail ; do
347
- set -o $option
348
- done
349
- export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
350
- else
351
- set -x
426
+ export PS4='+${BASH_SOURCE} : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() : }'
352
427
  fi
353
- ;;
354
- --debug)
355
- rvm_debug_flag=1
356
- local option="" ;
357
- for option in verbose errtrace ; do
358
- set -o $option
359
- done
428
+ fi
360
429
  ;;
430
+
361
431
  -q|--quiet) rvm_quiet_flag=1 ;;
432
+
362
433
  -s|--silent) rvm_silent_flag=1 ;;
363
- --proxy) rvm_proxy="$next_token" ; shift ;;
434
+
435
+ --proxy)
436
+ rvm_proxy="$next_token"
437
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
438
+ ;;
439
+
364
440
  --disable-llvm|--disable-jit) rvm_llvm_flag=0 ;;
365
441
  --enable-llvm|--enable-jit) rvm_llvm_flag=1 ;;
366
442
 
@@ -371,7 +447,8 @@ __rvm_parse_args() {
371
447
  ;;
372
448
 
373
449
  --dump-environment)
374
- export rvm_dump_environment_flag="$next_token"; shift
450
+ export rvm_dump_environment_flag="$next_token"
451
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
375
452
  ;;
376
453
 
377
454
  --clang)
@@ -383,7 +460,8 @@ __rvm_parse_args() {
383
460
  -j)
384
461
  if [[ ! -z "$next_token" ]] ; then
385
462
  rvm_make_flags="$rvm_make_flags -j$next_token"
386
- shift
463
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
464
+
387
465
  else
388
466
  rvm_action="error"
389
467
  rvm_error_message="-j *must* be followed by an integer (normally the # of CPU's in your machine)."
@@ -392,13 +470,15 @@ __rvm_parse_args() {
392
470
 
393
471
  --with-rubies)
394
472
  rvm_ruby_strings="$next_token"
395
- shift
473
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
474
+
396
475
  ;;
397
476
 
398
477
  -C|--configure)
399
478
  if [[ ! -z "$next_token" ]] ; then
400
479
  rvm_ruby_configure_flags="$(echo $next_token | sed -e 's#,--# --#g')"
401
- shift
480
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
481
+
402
482
  else
403
483
  rvm_action="error"
404
484
  rvm_error_message="--configure *must* be followed by configure flags."
@@ -416,11 +496,11 @@ __rvm_parse_args() {
416
496
  rvm_error_message="-I|--include *must* be followed by a path."
417
497
  else
418
498
  rvm_ruby_load_path="$rvm_ruby_load_path:$next_token"
419
- shift
499
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
420
500
  fi
421
501
  ;;
422
502
 
423
- --) rvm_ruby_args="$*" ; rvm_parse_break=1 ;;
503
+ --) rvm_ruby_args="$next_token $*" ; rvm_parse_break=1 ;;
424
504
 
425
505
  *)
426
506
  if [[ -n "$rvm_token" ]] ; then
@@ -480,8 +560,8 @@ __rvm_parse_args() {
480
560
 
481
561
  else
482
562
  if "$rvm_scripts_path/match" "$rvm_token" ".rb$" ; then # we have a specified ruby script
483
- rvm_ruby_args=$rvm_token
484
- rvm_ruby_file=$rvm_token
563
+ rvm_ruby_args="$rvm_token"
564
+ rvm_ruby_file="$rvm_token"
485
565
  if [[ -z "${rvm_action:-""}" ]] ; then rvm_action="ruby" ; fi
486
566
  else
487
567
  rvm_action="error"
@@ -493,9 +573,7 @@ __rvm_parse_args() {
493
573
  rvm_error_message="Unrecognized command line argument(s): '$rvm_token $@'"
494
574
  fi
495
575
 
496
- if [[ "error" = "${rvm_action:-""}" ]] ; then
497
- break;
498
- fi
576
+ if [[ "error" = "${rvm_action:-""}" ]] ; then break ; fi
499
577
  esac
500
578
 
501
579
  if [[ -z "${rvm_action:-""}" && -n "${rvm_ruby_string:-""}" ]] ; then rvm_action="use" ; fi
@@ -507,11 +585,9 @@ __rvm_parse_args() {
507
585
  while [[ $# -gt 0 ]] ; do shift ; done
508
586
 
509
587
  if [[ -n "${rvm_error_message:-""}" ]] ; then
510
- __rvm_pushpop
511
588
  "$rvm_scripts_path"/log "fail" "$rvm_error_message ( see: 'rvm usage' )"
512
589
  return 1
513
590
  fi
514
-
515
591
  }
516
592
 
517
593
  rvm() {
@@ -530,7 +606,7 @@ rvm() {
530
606
  # Check that this is the current version.
531
607
  disk_version=$(tail -n 3 < "${rvm_path:-$HOME/.rvm}/lib/VERSION.yml" | sed -e 's/^.*: //g' | \tr "\n" '.' | sed -e 's/\.$//')
532
608
 
533
- if [[ $# -gt 0 ]] ; then next_token="$1" ; else next_token="" ; fi
609
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
534
610
 
535
611
  if [[ "${rvm_version}" != "${disk_version}" ]] && [[ "reload" != "$next_token" ]]; then
536
612
  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"
@@ -567,7 +643,7 @@ rvm() {
567
643
  help) "$rvm_scripts_path/help" $rvm_ruby_args ; result=$? ;;
568
644
  env) "$rvm_scripts_path/env" "$rvm_ruby_string" ; result=$? ;;
569
645
  info)
570
- if [[ $# -gt 0 ]] ; then next_token="$1" ; else next_token="" ; fi
646
+ if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
571
647
  if [[ "$next_token" = "info" ]]; then shift; fi
572
648
  "$rvm_scripts_path/info" $rvm_ruby_args
573
649
  result=$?
@@ -589,7 +665,7 @@ rvm() {
589
665
  old_rvm_ruby_string=$rvm_ruby_string
590
666
  unset rvm_ruby_string
591
667
  export rvm_ruby_strings
592
- "$rvm_scripts_path/set" "$rvm_action" "$rvm_ruby_args"
668
+ "$rvm_scripts_path/set" "$rvm_action" $rvm_ruby_args
593
669
  result=$?
594
670
  # Restore the state pre-sets.
595
671
  [[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string
@@ -652,7 +728,6 @@ rvm() {
652
728
  ;;
653
729
 
654
730
  error)
655
- __rvm_pushpop
656
731
  result=1
657
732
  ;;
658
733