rvm 1.0.2 → 1.0.3

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.
data/scripts/docs CHANGED
@@ -56,7 +56,11 @@ generate_rdoc() {
56
56
  __rvm_pushpop
57
57
  }
58
58
 
59
- case "$1" in
59
+ args=($*)
60
+ action="${args[0]}"
61
+ args="$(echo ${args[@]:1}) " # Strip trailing / leading / extra spacing.
62
+
63
+ case "$action" in
60
64
  open) open_docs ;;
61
65
  generate) generate_ri; generate_rdoc ;;
62
66
  generate-ri) generate_ri ;;
data/scripts/env CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
+ if [[ "$rvm_trace_flag" -eq 2 ]] ; then set -x ; export rvm_trace_flag ; fi
4
+
3
5
  # Recursive loops, oh my!
4
6
  unset rvm_default_flag
5
7
 
@@ -9,7 +11,8 @@ usage() {
9
11
  printf "Usage: rvm env [ruby_string] [--path]\n"
10
12
  }
11
13
 
12
- environment_name="$1"
14
+ args=($*)
15
+ environment_name="${args[0]}"
13
16
 
14
17
  if [[ -z "$environment_name" ]]; then
15
18
  usage ; exit 1
@@ -47,8 +47,10 @@ ensure_has_shell() {
47
47
  done; unset item
48
48
  }
49
49
 
50
- shell_name="$1"
51
- environment_name="${2:-"$(__rvm_environment_identifier)"}"
50
+ args=($*)
51
+ shell_name="${args[0]}"
52
+ environment_name="${args[1]:-"$(__rvm_environment_identifier)"}"
53
+ args="$(echo ${args[@]:2}) " # Strip trailing / leading / extra spacing.
52
54
 
53
55
  [[ -n "$shell_name" && -n "$environment_name" ]] || exit 1
54
56
  ensure_has_shell "$shell_name" || exit 1
data/scripts/fetch CHANGED
@@ -22,6 +22,8 @@ record_md5() {
22
22
 
23
23
  builtin cd "$rvm_archives_path"
24
24
 
25
+ # args=($*) # Reserved for future use
26
+
25
27
  if [[ -z "$1" ]] ; then "$rvm_scripts_path/log" "fail" "BUG: $0 called without an argument :/" ; exit 1 ; fi
26
28
 
27
29
  url="$1"; download=1 ; package_name="$2"
data/scripts/gemsets CHANGED
@@ -3,20 +3,30 @@
3
3
  source "$rvm_scripts_path/base"
4
4
 
5
5
  rvm_ruby_gem_home="${rvm_ruby_gem_home:-$GEM_HOME}"
6
+
6
7
  if [[ ! -d "$rvm_ruby_gem_home" ]] && command -v gem > /dev/null 2>&1; then rvm_ruby_gem_home="$(gem env home)" ; fi
7
8
 
8
9
  usage() {
9
- printf "Usage: 'rvm gemset action'\n"
10
- printf " where action is one of: {import,export,create,copy,empty,delete,name,dir,list,gemdir,install,pristine,clear,use,update,globalcache}\n"
11
- printf "\n"
12
- printf " Tools for working with and manipulating gemsets within rvm.\n"
13
- exit 1
10
+ printf "
11
+ Usage:
12
+
13
+ rvm gemset [action]
14
+
15
+ Action:
16
+
17
+ {import,export,create,copy,empty,delete,name,dir,list,gemdir,install,pristine,clear,use,update,globalcache}
18
+
19
+ Description:
20
+
21
+ Commands for working with and manipulating gemsets within RVM.
22
+
23
+ "
14
24
  }
15
25
 
16
26
  gemset_update() {
17
27
  if [[ -z "$rvm_ruby_strings" ]]; then
18
28
  "$rvm_scripts_path/log" "info" "Running gem update for all rubies and gemsets."
19
- rvm_ruby_strings="$(\ls "$rvm_gems_path" | \grep -v '^\(doc\|cache\|@\|system\)' | \tr '\n' ',')"
29
+ rvm_ruby_strings="$(ls "$rvm_gems_path" | grep -v '^\(doc\|cache\|@\|system\)' | \tr '\n' ',')"
20
30
  else
21
31
  "$rvm_scripts_path/log" "info" "Running gem update for the specified rubies."
22
32
  fi
@@ -39,99 +49,126 @@ gemset_globalcache() {
39
49
  return "$globalcache_enabled"
40
50
  elif [[ "$1" == "disable" ]]; then
41
51
  "$rvm_scripts_path/log" "info" "Removing the global cache (note: this will empty the caches)"
42
- for directory_name in $(\ls "$rvm_gems_path"); do
52
+ for directory_name in $(ls "$rvm_gems_path"); do
43
53
  current_cache_path="$rvm_gems_path/$directory_name/cache"
44
54
  if [[ -L "$current_cache_path" && "$(readlink "$current_cache_path")" == "$rvm_gems_cache_path" ]]; then
45
55
  "$rvm_scripts_path/log" "info" "Reverting the gem cache for $directory_name to an empty directory."
46
- \rm -f "$current_cache_path" 2>/dev/null
47
- \mkdir -p "$current_cache_path" 2>/dev/null
56
+ rm -f "$current_cache_path" 2>/dev/null
57
+ mkdir -p "$current_cache_path" 2>/dev/null
48
58
  fi
49
59
  done; unset full_directory_path directory_name
50
60
  "$rvm_scripts_path/db" "$rvm_config_path/user" "use_gemset_globalcache" "delete"
51
61
  elif [[ "$1" == "enable" ]]; then
52
62
  "$rvm_scripts_path/log" "info" "Enabling global cache for gems."
53
- \mkdir -p "$rvm_gems_cache_path"
54
- for directory_name in $(\ls "$rvm_gems_path"); do
63
+ mkdir -p "$rvm_gems_cache_path"
64
+ for directory_name in $(ls "$rvm_gems_path"); do
55
65
  current_cache_path="$rvm_gems_path/$directory_name/cache"
56
66
  if [[ -d "$current_cache_path" && ! -L "$current_cache_path" ]]; then
57
67
  "$rvm_scripts_path/log" "info" "Moving the gem cache for $directory_name to the global cache."
58
68
  mv "$current_cache_path/"*.gem "$rvm_gems_cache_path/" 2>/dev/null
59
- \rm -rf "$current_cache_path"
69
+ rm -rf "$current_cache_path"
60
70
  ln -nfs "$rvm_gems_cache_path" "$current_cache_path"
61
71
  fi
62
72
  done; unset full_directory_path directory_name
63
73
  "$rvm_scripts_path/db" "$rvm_config_path/user" "use_gemset_globalcache" "true"
64
74
  else
65
- printf "Usage: 'rvm gemset globalcache {enable,disable}\n"
66
- printf " Enable / Disable the use of a global gem cachedir.\n"
75
+ printf "
76
+ Usage:
77
+
78
+ rvm gemset globalcache {enable,disable}
79
+
80
+ Enable / Disable the use of a global gem cachedir.
81
+
82
+ "
67
83
  return 1
68
84
  fi
69
85
  }
70
86
 
71
87
  gemset_name() {
72
88
  gemset_dir | awk -F${rvm_gemset_separator} '{print $2}'
89
+ return $?
73
90
  }
74
91
 
75
92
  gemset_dir() {
76
93
  echo "$rvm_ruby_gem_home"
94
+ return $?
77
95
  }
78
96
 
79
97
  gemset_create() {
98
+ local gem_home=""
99
+
80
100
  rvm_ruby_gem_prefix=$(echo $rvm_ruby_gem_home | sed 's/'${rvm_gemset_separator}'.*$//')
101
+
81
102
  for gemset in $(echo $gems_args) ; do
82
103
  if [[ "$gemset" == *"${rvm_gemset_separator}"* ]]; then
83
104
  "$rvm_scripts_path/log" "error" "Can't do that, it contains a \"${rvm_gemset_separator}\"."
84
105
  continue
85
106
  fi
107
+
86
108
  gem_home="${rvm_ruby_gem_prefix}${rvm_gemset_separator}${gemset}"
87
- \mkdir -p "$gem_home"
109
+
110
+ mkdir -p "$gem_home"
111
+
88
112
  # When the globalcache is enabled, we need to ensure we setup the cache directory correctly.
89
113
  if __rvm_using_gemset_globalcache; then
90
114
  if [[ -d "$gem_home/cache" && ! -L "$gem_home/cache" ]]; then
91
115
  mv "$gem_home/cache"/*.gem "$rvm_gems_cache_path/" 2>/dev/null
92
- \rm -rf "$gem_home/cache"
116
+ rm -rf "$gem_home/cache"
93
117
  fi
94
118
  ln -nfs "$rvm_gems_cache_path" "$gem_home/cache"
95
119
  fi
120
+
96
121
  "$rvm_scripts_path/log" "info" "Gemset '$gemset' created."
97
- done ; unset gem_home
122
+ done
123
+ return 0
98
124
  }
99
125
 
100
126
  gemset_list() {
101
- if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
127
+ rvm_ruby_selected_flag=${rvm_ruby_selected_flag:-0}
128
+ rvm_gems_path="${rvm_gems_path:-""}"
129
+ rvm_ruby_string="${rvm_ruby_string:-""}"
130
+
131
+ if [[ $rvm_ruby_selected_flag -eq 0 ]] ; then __rvm_select ; fi
102
132
 
103
- "$rvm_scripts_path/log" "info" "gemsets : for $rvm_ruby_string (found in $rvm_gems_path/)"
133
+ "$rvm_scripts_path/log" "info" "gemsets for $rvm_ruby_string (found in $rvm_gems_path/$rvm_ruby_string)\n"
104
134
 
105
- if [[ ! -z "$rvm_gems_path" ]] ; then
106
- if [[ ! -z "$rvm_ruby_string" ]] ; then
107
- \ls "${rvm_gems_path}/" | awk -F"${rvm_gemset_separator}" "/${rvm_ruby_string}${rvm_gemset_separator}/{print \$2}" 2>/dev/null
135
+ if [[ -n "$rvm_gems_path" ]] ; then
136
+ if [[ -n "$rvm_ruby_string" ]] ; then
137
+ ls "${rvm_gems_path}/" | awk -F"${rvm_gemset_separator}" "/${rvm_ruby_string}${rvm_gemset_separator}/{print \$2}" 2>/dev/null
108
138
  else
109
139
  "$rvm_scripts_path/log" "error" "\$rvm_ruby_string is not set!"
140
+ return 1
110
141
  fi
111
142
  else
112
143
  "$rvm_scripts_path/log" "error" "\$rvm_gems_path is not set!"
144
+ return 1
113
145
  fi
146
+ printf "\n"
147
+ return 0
114
148
  }
115
149
 
116
150
  gemset_delete() {
117
- if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
118
- if [[ ! -z "$rvm_gemset_name" ]] ; then
151
+ rvm_ruby_selected_flag=${rvm_ruby_selected_flag:-0}
152
+
153
+ if [[ $rvm_ruby_selected_flag -eq 0 ]] ; then __rvm_select ; fi
154
+
155
+ if [[ -n "$rvm_gemset_name" ]] ; then
119
156
  gemdir="$rvm_gems_path/$rvm_ruby_string${rvm_gemset_separator}$rvm_gemset_name"
120
157
  if [[ -d "$gemdir" ]] && [[ "$gemdir" != '/' ]] && [[ ! -z "$rvm_force_flag" ]] ; then
121
- \rm -rf "$gemdir"
158
+ rm -rf "$gemdir"
122
159
  elif [[ -d "$gemdir" ]] ; then
123
160
  "$rvm_scripts_path/log" "warn" "Are you SURE you wish to remove the entire gemset directory '$rvm_gemset_name' ($gemdir)?"
124
161
  echo -n "(anything other than 'yes' will cancel) > "
125
162
  read response
126
163
  if [[ "yes" = "$response" ]] ; then
127
- \rm -f $gemdir/cache 2>/dev/null
128
- \rm -rf $gemdir
164
+ rm -f $gemdir/cache 2>/dev/null
165
+ rm -rf $gemdir
129
166
  else
130
167
  "$rvm_scripts_path/log" "info" "Not doing anything, phew... close call that one eh?"
131
168
  fi
132
169
  else
133
170
  "$rvm_scripts_path/log" "info" "$gemdir already does not exist."
134
- fi ; unset gemdir
171
+ fi
135
172
  else
136
173
  "$rvm_scripts_path/log" "error" "A gemset name must be specified in order to delete a gems."
137
174
  fi
@@ -141,13 +178,13 @@ gemset_empty() {
141
178
  if [[ -z "$rvm_ruby_gem_home" ]] ; then __rvm_select ; fi
142
179
  gemdir="$rvm_ruby_gem_home"
143
180
  if [[ -d "$gemdir" ]] && [[ "$gemdir" != '/' ]] && [[ ! -z "$rvm_force_flag" ]] ; then
144
- builtin cd "$gemdir" && \rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
181
+ builtin cd "$gemdir" && rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
145
182
  elif [[ -d "$gemdir" ]] ; then
146
183
  "$rvm_scripts_path/log" "warn" "Are you SURE you wish to remove the installed gemset for gemset '$(basename "$gemdir")' ($gemdir)?"
147
184
  echo -n "(anything other than 'yes' will cancel) > "
148
185
  read response
149
186
  if [[ "yes" = "$response" ]] ; then
150
- builtin cd "$gemdir" && \rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
187
+ builtin cd "$gemdir" && rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
151
188
  else
152
189
  "$rvm_scripts_path/log" "info" "Not doing anything, phew... close call that one eh?"
153
190
  fi
@@ -180,11 +217,11 @@ gemset_copy() {
180
217
  fi
181
218
 
182
219
  if [[ -d "$source_path" ]] ; then
183
- [[ ! -d "$destination_path" ]] && \mkdir -p "$destination_path"
220
+ [[ ! -d "$destination_path" ]] && mkdir -p "$destination_path"
184
221
  "$rvm_scripts_path/log" "info" "Copying gemset from $source_ruby to $destination_ruby"
185
222
  for dir in bin doc gems specifications cache ; do
186
- \mkdir -p "$destination_path/$dir"
187
- \cp -Rf "$source_path/$dir" "$destination_path/"
223
+ mkdir -p "$destination_path/$dir"
224
+ cp -Rf "$source_path/$dir" "$destination_path/"
188
225
  done
189
226
  "$rvm_scripts_path/log" "info" "Making gemset for $destination_ruby pristine."
190
227
  __rvm_run_with_env "gemset.pristine" "$destination_ruby" "rvm gemset pristine"
@@ -213,9 +250,9 @@ gemset_export() {
213
250
 
214
251
  "$rvm_scripts_path/log" "info" "Exporting current environments gemset to $rvm_file_name"
215
252
 
216
- \touch "$rvm_file_name"
253
+ touch "$rvm_file_name"
217
254
  echo "# $rvm_file_name generated gem export file. Note that any env variable settings will be missing. Append these after using a ';' field separator" > "$rvm_file_name"
218
- for gem in $(gem list | sed 's#[\(|\)]##g' | sed 's#, #,#g' | \tr ' ' ';') ; do
255
+ for gem in $(gem list | sed 's#[\(|\)]##g' | sed 's#, #,#g' | tr ' ' ';') ; do
219
256
  name="${gem/;*/}"
220
257
  if [[ -z "$rvm_latest_flag" ]] ; then
221
258
  versions="${gem/*;/}" ; versions="${versions//,/ }"
@@ -229,18 +266,18 @@ gemset_export() {
229
266
  }
230
267
 
231
268
  gemset_import() {
232
-
233
269
  if [[ ! -z "$rvm_ruby_gem_home" ]] ; then
234
270
  export GEM_HOME="$rvm_ruby_gem_home"
235
271
  export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_gems_path/$rvm_ruby_string${rvm_gemset_separator}global/bin"
236
272
  export BUNDLE_PATH="$rvm_ruby_gem_home"
237
273
  fi
238
274
 
239
- rvm_gemset_name="${gems_args//.gem*/}"
240
- rvm_gemset_name="${gems_args// /}"
275
+ rvm_file_name="${gems_args}"
241
276
 
242
- if [[ -s "$rvm_gemset_name.gems" ]] ; then
243
- rvm_file_name="$rvm_gemset_name.gems"
277
+ if [[ -s "${rvm_file_name%.gems*}.gems" ]] ; then
278
+ rvm_file_name="${rvm_file_name%.gems*}.gems"
279
+ elif [[ -s "${rvm_gemset_name}.gems" ]] ; then
280
+ rvm_file_name="${rvm_gemset_name}.gems"
244
281
  elif [[ -s "default.gems" ]] ; then
245
282
  rvm_file_name="default.gems"
246
283
  elif [[ -s "system.gems" ]] ; then
@@ -252,11 +289,11 @@ gemset_import() {
252
289
  return 1
253
290
  fi
254
291
 
255
- \mkdir -p "$rvm_gems_cache_path" # Ensure the base cache dir is initialized.
292
+ mkdir -p "$rvm_gems_cache_path" # Ensure the base cache dir is initialized.
256
293
 
257
294
  if [[ -s "$rvm_file_name" ]] ; then
258
295
  echo "Importing $rvm_file_name file..."
259
- rvm_ruby_gem_list=$(\ls "$rvm_ruby_gem_home/specifications/" 2> /dev/null | sed 's#.gems.*$##' 2> /dev/null)
296
+ rvm_ruby_gem_list=$(ls "$rvm_ruby_gem_home/specifications/" 2> /dev/null | sed 's#.gems.*$##' 2> /dev/null)
260
297
 
261
298
  while read -r line
262
299
  do # Keep this on 2nd line :(
@@ -270,8 +307,12 @@ gemset_import() {
270
307
  }
271
308
 
272
309
  __rvm_parse_gems_args() {
273
- gem="${gems_args/;*}"
274
- gem_prefix="${gems_args/*;}"
310
+
311
+ gem="${gems_args/;*}" ; gem_prefix=""
312
+ if echo "$gems_args" | grep -q ';' ; then
313
+ gem_prefix="${gems_args/*;}"
314
+ fi
315
+
275
316
  if "$rvm_scripts_path/match" "$gem" ".gem$" ; then
276
317
  gem_name="$(basename "${gem/.gem/}" | awk -F'-' '{$NF=NULL;print}')"
277
318
  gem_version="$(basename "${gem/.gem/}" | awk -F'-' '{print $NF}' )"
@@ -316,16 +357,16 @@ gem_install() {
316
357
  elif [[ -s "$(__rvm_current_gemcache_dir)/${gem_file_name}" ]] ; then
317
358
  cache_file="$(__rvm_current_gemcache_dir)/${gem_file_name}"
318
359
  else
319
- cache_file="${cache_file:-$(\ls "$(__rvm_current_gemcache_dir)/${gem_file_name}" 2> /dev/null | sort | head -n1)}"
360
+ cache_file="${cache_file:-$(ls "$(__rvm_current_gemcache_dir)/${gem_file_name}" 2> /dev/null | sort | head -n1)}"
320
361
  fi
321
362
 
322
363
  if [[ ! -s "$cache_file" ]] ; then
323
364
  if [[ -s "$gem_file_name" ]] ; then
324
365
  gem="$gem_file_name"
325
- elif [[ -z "${gem_version/ /}" ]] ; then
326
- gem="${gem_name/ /}"
366
+ elif [[ -z "${gem_version// /}" ]] ; then
367
+ gem="${gem_name// /}"
327
368
  else
328
- gem="${gem_name/ /} -v $gem_version"
369
+ gem="${gem_name// /} -v $gem_version"
329
370
  fi
330
371
  else # cached
331
372
  gem_file_name="$(basename "$cache_file")"
@@ -336,7 +377,7 @@ gem_install() {
336
377
  "$rvm_scripts_path/log" "info" "$gem_name $gem_version exists, skipping (--force to re-install)"
337
378
  else
338
379
  if [[ -s "$(__rvm_current_gemcache_dir)/$(basename $gem_file_name)" ]] ; then
339
- \mkdir -p "$rvm_tmp_path/$$/"
380
+ mkdir -p "$rvm_tmp_path/$$/"
340
381
  mv "$(__rvm_current_gemcache_dir)/$gem_file_name" "$rvm_tmp_path/$$/$gem_file_name"
341
382
  gem="$rvm_tmp_path/$$/$gem_file_name -f -l"
342
383
  else
@@ -352,17 +393,17 @@ gem_install() {
352
393
  if [[ "rvm_make_flags_flag" -eq 1 ]] ; then __rvm_make_flags ; fi
353
394
 
354
395
  if [[ ! -z "$rvm_ruby_gem_home" ]] && [[ "$rvm_ruby_gem_home" != "$rvm_gems_path" ]] ; then
355
- command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home/bin:$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator}global/bin' BUNDLE_PATH='${rvm_ruby_gem_home}' ${gem_prefix} gem install $gems_args $rvm_gem_options $gem_postfix $vars"
396
+ command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home/bin:$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator}global/bin' BUNDLE_PATH='${rvm_ruby_gem_home}' ${gem_prefix} command gem install $gems_args $rvm_gem_options $gem_postfix $vars"
356
397
  else
357
398
  #--ignore-dependencies
358
- command="$gem_prefix gem install --ignore-dependencies $gems_args $rvm_gem_options -q $gem $gem_postfix $vars"
399
+ command="$gem_prefix command gem install --ignore-dependencies $gems_args $rvm_gem_options -q $gem $gem_postfix $vars"
359
400
  fi
360
401
  __rvm_run "gem.install" "$command" "installing ${gem_name} ${gem_version}..."
361
402
  result=$?
362
403
  if [[ $result -eq 0 ]] ; then
363
- "$rvm_scripts_path/log" "info" "$gem_name $gem_version installed, output logged to:\n$rvm_path/log/$rvm_ruby_string/gem.install.log"
404
+ "$rvm_scripts_path/log" "info" "$gem_name $gem_version installed ( output logged to: $rvm_path/log/$rvm_ruby_string/gem.install.log )"
364
405
  else
365
- "$rvm_scripts_path/log" "error" "$gem_name $gem_version failed to install, output logged to:\n$rvm_path/log/$rvm_ruby_string/gem.install.error.log"
406
+ "$rvm_scripts_path/log" "error" "$gem_name $gem_version failed to install ( output logged to: $rvm_path/log/$rvm_ruby_string/gem.install.error.log )"
366
407
  fi
367
408
  fi ; unset gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string gem_action
368
409
 
@@ -372,7 +413,7 @@ gem_install() {
372
413
  # Output the user's current gem directory.
373
414
  gemset_info() {
374
415
  if [[ "$rvm_user_flag" -eq 1 ]] ; then
375
- echo $(rvm system ; gem env | \grep "\- $HOME" | awk '{print $NF}')
416
+ echo $(rvm system ; gem env | grep "\- $HOME" | awk '{print $NF}')
376
417
  elif [[ "$rvm_system_flag" -eq 1 ]] ; then
377
418
  echo $(rvm system ; gem env $action system)
378
419
  elif [[ ! -z "$rvm_ruby_string" ]] ; then
@@ -382,12 +423,13 @@ gemset_info() {
382
423
  else
383
424
  gem env $action
384
425
  fi
426
+ return $?
385
427
  }
386
428
 
387
429
  gemset_prune() {
388
430
  temporary_cache_path="$GEM_HOME/temporary-cache"
389
431
  live_cache_path="$GEM_HOME/cache"
390
- \mkdir -p "$temporary_cache_path"
432
+ mkdir -p "$temporary_cache_path"
391
433
  "$rvm_scripts_path/log" "info" "Moving active gems into temporary cache..."
392
434
  while read -r used_gem; do
393
435
  gem_name="$(echo "$used_gem" | sed -e 's/ .*//')"
@@ -402,33 +444,48 @@ gemset_prune() {
402
444
  done < <(gem list --versions)
403
445
  "$rvm_scripts_path/log" "info" "Removing live cache and restoring temporary cache..."
404
446
  # Switch the cache back.
405
- \rm -rf "$live_cache_path"
447
+ rm -rf "$live_cache_path"
406
448
  mv "$temporary_cache_path" "$live_cache_path"
449
+ return 0
407
450
  }
408
451
 
409
452
  gemset_pristine() {
410
- gem pristine --all
453
+ if command -v gem > /dev/null ; then
454
+ gem pristine --all
455
+ return $?
456
+ else
457
+ "$rvm_scripts_path/log" "error" "'gem' command not found in PATH"
458
+ return 1
459
+ fi
411
460
  }
412
461
 
413
462
  # Loads the default gemsets for the current interpreter and gemset.
414
463
  gemset_initial() {
415
464
  "$rvm_scripts_path/log" "info" "Importing initial gemsets for $(__rvm_environment_identifier)."
416
- \mkdir -p "$rvm_gemsets_path/$(echo "$rvm_ruby_string" | \tr '-' '/')" 2>/dev/null
465
+
466
+ mkdir -p "$rvm_gemsets_path/${rvm_ruby_string//-//}" 2>/dev/null
467
+
417
468
  for gemsets_path in $(__rvm_ruby_string_paths_under "$rvm_gemsets_path") ; do
418
- if [[ -n "$rvm_gemset_name" ]] ; then
419
- if [[ -s "${gemsets_path}/${rvm_gemset_name}.gems" ]] ; then
420
- (source "$rvm_scripts_path/rvm"; rvm gemset import "${gemsets_path}/${rvm_gemset_name}.gems") > /dev/null
469
+ # TODO: This can be condensed.
470
+ if [[ -d "$gemsets_path" ]] ; then
471
+
472
+ if [[ -n "$rvm_gemset_name" && -s "${gemsets_path}/${rvm_gemset_name}.gems" ]] ; then
473
+ ( rvm --create use "$rvm_ruby_string" ; "$rvm_scripts_path/gemsets" import "${gemsets_path}/${rvm_gemset_name}.gems" )
421
474
  fi
422
- else
423
- if [[ -d "$gemsets_path" ]] && [[ -s "${gemsets_path}/default.gems" ]] ; then
424
- (source "$rvm_scripts_path/rvm"; rvm gemset import "$gemsets_path/default.gems") > /dev/null
475
+
476
+ if [[ -s "${gemsets_path}/default.gems" ]] ; then
477
+ ( rvm --create use "$rvm_ruby_string" ; "$rvm_scripts_path/gemsets" import "$gemsets_path/default.gems" )
425
478
  fi
426
- if [[ -d "$gemsets_path" ]] && [[ -s "${gemsets_path}/global.gems" ]] ; then
427
- (source "$rvm_scripts_path/rvm"; rvm use "$rvm_ruby_string@global" --create ; rvm gemset import "${gemsets_path}/global.gems") > /dev/null
479
+
480
+ if [[ -s "${gemsets_path}/global.gems" ]] ; then
481
+ ( rvm --create use "$rvm_ruby_string@global" ; "$rvm_scripts_path/gemsets" import "${gemsets_path}/global.gems" )
428
482
  fi
429
483
  fi
430
484
  done
485
+
431
486
  "$rvm_scripts_path/log" "info" "Installation of gems for $(__rvm_environment_identifier) is complete."
487
+
488
+ return 0
432
489
  }
433
490
 
434
491
  unset GEM_PATH
@@ -438,16 +495,19 @@ if ! command -v gem > /dev/null ; then
438
495
  exit 1
439
496
  fi
440
497
 
441
- action="$(echo "$*" | awk '{print $1}')"
442
- gems_args="$(echo "$*" | awk '{$1="" ; print}' | __rvm_strip)"
443
- export rvm_gemset_name
498
+ args=($*)
499
+ action="${args[0]}"
500
+ gems_args="$(echo ${args[@]:1}) " # Strip trailing / leading / extra spacing.
501
+
502
+ export rvm_gemset_name="${args[1]}" # For wherever used.
503
+ rvm_sticky_flag=1
444
504
 
445
505
  if [[ "import" = "$action" ]] || [[ "load" = "$action" ]] ; then
446
506
  if [[ -z "$rvm_ruby_strings" ]]; then
447
507
  gemset_import
448
508
  else
449
509
  original_env="$(__rvm_environment_identifier)"
450
- for rvm_ruby_string in $(echo "$rvm_ruby_strings" | \tr "," " "); do
510
+ for rvm_ruby_string in $(echo "$rvm_ruby_strings" | tr "," " "); do
451
511
  __rvm_become
452
512
  gemset_import
453
513
  done
@@ -487,8 +547,10 @@ elif [[ "globalcache" = "$action" ]]; then
487
547
  elif [[ "clear" = "$action" ]] ; then
488
548
  "$rvm_scripts_path/log" "info" "gemset cleared."
489
549
  exit 0
550
+ elif [[ "help" = "$action" ]] ; then
551
+ usage ; exit 0
490
552
  else
491
- usage
553
+ usage ; exit 1
492
554
  fi
493
555
 
494
556
  exit $?