rvm 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ add(){
10
10
  fi
11
11
  }
12
12
 
13
- rvm_gemset_separator=${rvm_gemset_separator:-"+"}
13
+ rvm_gemset_separator="${rvm_gemset_separator:-"@"}"
14
14
  ruby=$(command -v ruby)
15
15
  if [[ ! -z "$ruby" ]] && [[ ! -z "$(echo "$ruby" | awk '/rvm/{print}')" ]] ; then
16
16
  unset format
@@ -41,31 +41,30 @@ if [[ ! -z "$ruby" ]] && [[ ! -z "$(echo "$ruby" | awk '/rvm/{print}')" ]] ; the
41
41
 
42
42
  # Dont' display anything if no default flag was provided and we're using the default ruby
43
43
  if [[ -n "$no_default" && "$(rvm tools identifier)" = "$(rvm alias show default)" ]]; then
44
- exit 0
44
+ exit 0
45
45
  fi
46
46
 
47
- if [[ ! -z "$interpreter_flag" ]] || [[ ! -z "$unicode_flag" ]] ; then
48
- interpreter="$(echo $ruby_string | awk -F'-' '{print $1}')"
47
+ if [[ -n "$interpreter_flag" ]] || [[ ! -z "$unicode_flag" ]] ; then
48
+ interpreter="${ruby_string/-*/}"
49
49
  fi
50
50
 
51
- if [[ ! -z "$version_flag" ]] || [[ ! -z "$unicode_flag" ]] ; then
52
- version="$(echo $ruby_string | awk -F'-' '{print $2}')"
51
+ if [[ -n "$version_flag" ]] || [[ ! -z "$unicode_flag" ]] ; then
52
+ version="${ruby_string%-*}" ; version="${version#*-}"
53
53
  fi
54
54
 
55
- if [[ ! -z "$patchlevel_flag" ]] ; then
56
- patchlevel=$(echo $ruby_string | awk -F'-' '{print $3}')
55
+ if [[ -n "$patchlevel_flag" ]] ; then
56
+ patchlevel="${ruby_string##*-}"
57
57
  fi
58
58
 
59
- if [[ ! -z "$architecture_flag" ]] ; then
59
+ if [[ -n "$architecture_flag" ]] ; then
60
60
  architecture="$(echo "$(ruby -v)" | sed 's/^.*\[//' | sed 's/\].*$//')"
61
61
  fi
62
62
 
63
- if [[ ! -z "$gemset_flag" ]] ; then
64
- gemset="$(echo $GEM_HOME | awk -F${rvm_gemset_separator} '{print $2}')"
65
- if [[ ! -z "$gemset" ]] ; then gemset="${rvm_gemset_separator}$gemset" ; fi
63
+ if [[ -n "$gemset_flag" && "$GEM_HOME" =~ ${rvm_gemset_separator} ]] ; then
64
+ gemset="${rvm_gemset_separator}${GEM_HOME/*${rvm_gemset_separator}/}"
66
65
  fi
67
66
 
68
- if [[ ! -z "$unicode_flag" ]] ; then
67
+ if [[ -n "$unicode_flag" ]] ; then
69
68
  case "$interpreter" in
70
69
  jruby) unicode="☯" ;;
71
70
  rbx) unicode="☃" ;;
@@ -86,15 +85,15 @@ if [[ ! -z "$ruby" ]] && [[ ! -z "$(echo "$ruby" | awk '/rvm/{print}')" ]] ; the
86
85
  *) unicode="♢" ;;
87
86
  esac
88
87
 
89
- if [[ ! -z "$(echo $ruby_string | awk '/-head/')" ]] ; then
88
+ if echo "$ruby_string" | \grep -q '-head' ; then
90
89
  unicode="${unicode}〠"
91
90
  fi
92
91
  fi
93
-
92
+
94
93
  command="prompt=\"$format\""
95
94
  eval "$command"
96
95
  echo "$prompt" | sed -e 's#^[[:space:]]*-*##g' -e 's#--*#-#g' -e 's#-*[[:space:]]*$##' -e 's#-'${rvm_gemset_separator}'#'${rvm_gemset_separator}'#'
97
-
96
+
98
97
  else
99
98
  while [[ $# -gt 0 ]] ; do
100
99
  token="$1" ; shift
@@ -7,7 +7,7 @@ for gem in $(gem list | sed 's#[\(|\)]##g' | sed 's#, #,#g' | \tr ' ' ';') ; do
7
7
  name="$(echo $gem | awk -F';' '{print $1}')"
8
8
  versions="$(echo $gem | awk -F';' '{print $2}' | sed 's#,# #g')"
9
9
  for version in $versions ; do
10
- echo "$name -v$version" >> $file_name
10
+ echo "$name -v$version" >> "$file_name"
11
11
  done ; unset version versions
12
12
  done ; unset file_name
13
13
 
data/install CHANGED
@@ -76,7 +76,7 @@ if [[ -z "$rvm_path" ]] ; then rvm_path="${rvm_prefix}rvm" ; fi
76
76
 
77
77
  source scripts/initialize
78
78
 
79
- if \grep -q 'scripts/rvm' $HOME/.bash* 2>/dev/null || \grep -q 'scripts/rvm' $HOME/.zsh* 2>/dev/null; then
79
+ if \grep -q 'scripts/rvm' "$HOME"/.bash* 2>/dev/null || \grep -q 'scripts/rvm' "$HOME"/.zsh* 2>/dev/null; then
80
80
  if [[ -d "$rvm_path" ]] && [[ -s "${rvm_path}/scripts/rvm" ]] ; then
81
81
  export upgrade_flag=1
82
82
  else
@@ -93,7 +93,7 @@ __rvm_initialize
93
93
  #
94
94
  item="$(tput setaf 2)* $(tput sgr0)"
95
95
  question="\n$(tput setaf 2)<?>$(tput sgr0)"
96
- cwd=$PWD
96
+ cwd="$PWD"
97
97
  source_path="${source_path:-$cwd}"
98
98
  rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
99
99
  rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
@@ -151,7 +151,7 @@ done ; unset dir_name
151
151
  spinner
152
152
  if [[ ! -s "$rvm_config_path/user" ]] ; then
153
153
  \mkdir -p "$rvm_config_path/"
154
- echo '# Users settings file, overrides db file settings and persists across installs.' >> $rvm_config_path/user
154
+ echo '# Users settings file, overrides db file settings and persists across installs.' >> "$rvm_config_path/user"
155
155
  fi
156
156
 
157
157
  scripts=("monitor" "match" "log" "install" "color" "db" "fetch" "log" "set" "package")
@@ -170,7 +170,7 @@ for file in rvm-prompt rvm rvmsudo rvm-shell rvm-auto-ruby ; do
170
170
  \cp -f "$source_path/binscripts/$file" $rvm_bin_path/
171
171
  done
172
172
  spinner
173
- chmod +x $rvm_bin_path/*
173
+ chmod +x "$rvm_bin_path"/*
174
174
 
175
175
  #
176
176
  # RC Files
@@ -179,17 +179,17 @@ spinner
179
179
  if [[ -n "$rvm_auto_flag" ]] ; then
180
180
  printf "Checking rc files... ($rvm_rc_files)"
181
181
  if [[ "$rvm_loaded_flag" != "1" ]] ; then
182
- for rcfile in $(echo $rvm_rc_files) ; do
182
+ for rcfile in $(printf $rvm_rc_files) ; do
183
183
  if [[ ! -f $rcfile ]] ; then \touch $rcfile ; fi
184
184
  if [[ -s "$HOME/.profile" ]] ; then
185
185
  if ! \grep -q '.profile' "$rcfile" ; then
186
186
  echo " Adding 'if [[ -s \$HOME/.profile ]] ; then source \$HOME ; fi' to $rcfile."
187
- printf "\n# rvm-install added line:\nif [[ -s \$HOME/.profile ]] ; then source \$HOME/.profile ; fi\n" >> $rcfile
187
+ printf "\n# rvm-install added line:\nif [[ -s \$HOME/.profile ]] ; then source \$HOME/.profile ; fi\n" >> "$rcfile"
188
188
  fi
189
189
  fi
190
190
  if ! \grep -q "scripts\/rvm" "$rcfile" ; then
191
191
  echo " Adding 'if [[ -s $rvm_scripts_path/rvm ]] ; then source $rvm_scripts_path/rvm ; fi' to $rcfile."
192
- printf "\n# rvm-install added:\nif [[ -s $rvm_scripts_path/rvm ]] ; then source $rvm_scripts_path/rvm ; fi\n" >> $rcfile
192
+ printf "\n# rvm-install added:\nif [[ -s $rvm_scripts_path/rvm ]] ; then source $rvm_scripts_path/rvm ; fi\n" >> "$rcfile"
193
193
  fi
194
194
  done
195
195
  fi
@@ -254,26 +254,27 @@ done
254
254
  spinner
255
255
  printf "\r*" # Stop spinner.
256
256
 
257
- for gemset in $rvm_path/gems/*\%* ; do
257
+ for gemset in "$rvm_path"/gems/*\%* ; do
258
258
  new_path=${gemset/\%/${rvm_gemset_separator}}
259
259
  if [[ -d "$gemset" ]] && [[ ! -d "$new_path" ]] ; then
260
- printf "\n Renaming $(basename $gemset) to $(basename $new_path) for new gemset separator."
261
- mv $gemset $new_path
260
+ printf "\n Renaming $(basename "$gemset") to $(basename "$new_path") for new gemset separator."
261
+ mv "$gemset" "$new_path"
262
262
  fi
263
263
  done
264
264
 
265
- for gemset in $rvm_path/gems/*\+* ; do
265
+ for gemset in "$rvm_path"/gems/*\+* ; do
266
266
  new_path=${gemset/\+/${rvm_gemset_separator}}
267
267
  if [[ -d "$gemset" ]] && [[ ! -d "$new_path" ]] ; then
268
- printf "\n Renaming $(basename $gemset) to $(basename $new_path) for new gemset separator."
268
+ printf "\n Renaming $(basename "$gemset") to $(basename "$new_path") for new gemset separator."
269
269
  mv $gemset $new_path
270
270
  fi
271
271
  done
272
- for gemset in $rvm_path/gems/*\@ ; do
272
+
273
+ for gemset in "$rvm_path"/gems/*\@ ; do
273
274
  new_path=$(echo $gemset | sed -e 's#\@$##')
274
275
  if [[ -d "$gemset" ]] && [[ ! -d "$new_path" ]] ; then
275
- printf "\n Fixing: $(basename $gemset) to $(basename $new_path) for new gemset separator."
276
- mv $gemset $new_path
276
+ printf "\n Fixing: $(basename "$gemset") to $(basename "$new_path") for new gemset separator."
277
+ mv "$gemset" "$new_path"
277
278
  fi
278
279
  done
279
280
 
@@ -281,18 +282,16 @@ done
281
282
  if [[ -s "$rvm_config_path/default" ]]; then
282
283
  original_version="$(basename "$(\grep GEM_HOME "$rvm_config_path/default" | awk -F"'" '{print $2}' | sed "s#\%#${rvm_gemset_separator}#")")"
283
284
  if [[ -n "$original_version" ]]; then
284
- $rvm_scripts_path/alias create default "$original_version" &> /dev/null
285
- fi
286
- unset original_version
285
+ "$rvm_scripts_path/alias" create default "$original_version" &> /dev/null
286
+ fi ; unset original_version
287
287
  \rm -rf "$rvm_config_path/default"
288
288
  fi
289
289
 
290
290
  #
291
291
  # End of gemset migration.
292
292
  #
293
-
294
293
  printf "\n Correct permissions for base binaries in $rvm_bin_path..."
295
- \mkdir -p $rvm_bin_path
294
+ \mkdir -p "$rvm_bin_path"
296
295
  for file in rvm rvmsudo rvm-shell rvm-auto-ruby; do
297
296
  [[ -s "$rvm_bin_path/$file" ]] && chmod +x "$rvm_bin_path/$file"
298
297
  done; unset file
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 0
4
- :patch: 1
4
+ :patch: 2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rvm}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
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-08-27}
12
+ s.date = %q{2010-09-03}
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}
@@ -127,7 +127,6 @@ Gem::Specification.new do |s|
127
127
  "scripts/maglev",
128
128
  "scripts/man",
129
129
  "scripts/manage",
130
- "scripts/manpages",
131
130
  "scripts/match",
132
131
  "scripts/md5",
133
132
  "scripts/migrate",
@@ -2,21 +2,21 @@
2
2
 
3
3
  unset rvm_default_flag rvm_wrapper_name
4
4
 
5
- source $rvm_scripts_path/base
5
+ source "$rvm_scripts_path"/base
6
6
 
7
7
  alias_conflicts_with_ruby() {
8
8
  # If default exists, we should return true.
9
9
  [[ "$1" == "default" && ! -L "$rvm_rubies_path/default" ]] && return 1
10
10
  # Open for suggestions to a better way of doing this...
11
11
  alias_check_result="$(
12
- \. $rvm_scripts_path/initialize
13
- \. $rvm_scripts_path/selector
14
- export rvm_ruby_string="$1"
12
+ \. \"$rvm_scripts_path/initialize\"
13
+ \. \"$rvm_scripts_path/selector\"
14
+ export rvm_ruby_string=\"$1\"
15
15
  __rvm_ruby_string > /dev/null 2>&1
16
16
  echo "$?"
17
17
  )"
18
18
  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."
19
+ "$rvm_scripts_path"/log "error" "You are attempted to create an alias called '$1', which is recognized as a rvm ruby."
20
20
  return 0
21
21
  fi
22
22
  return 1
@@ -25,17 +25,21 @@ alias_conflicts_with_ruby() {
25
25
 
26
26
  show_alias() {
27
27
  if [[ -z "$alias_name" ]]; then
28
- $rvm_scripts_path/log "error" "usage: 'rvm alias show [alias_name]'"
28
+ "$rvm_scripts_path"/log "error" "usage: 'rvm alias show [alias_name]'"
29
29
  result=1
30
30
  return
31
31
  fi
32
- expanded_alias_name="$($rvm_scripts_path/db "$rvm_config_path/alias" "$alias_name")"
32
+ expanded_alias_name="$("$rvm_scripts_path"/db "$rvm_config_path/alias" "$alias_name")"
33
33
  if [[ -z "$expanded_alias_name" ]]; then
34
- $rvm_scripts_path/log "error" "Unknown alias name: '$alias_name'"
34
+ "$rvm_scripts_path"/log "error" "Unknown alias name: '$alias_name'"
35
35
  result=1
36
36
  else
37
37
  result=0
38
- echo "$expanded_alias_name"
38
+ if [[ -n "$gemset_name" ]] ; then
39
+ printf "${expanded_alias_name}${rvm_gemset_separator}${gemset_name}"
40
+ else
41
+ printf "$expanded_alias_name"
42
+ fi
39
43
  fi
40
44
  unset expanded_alias_name
41
45
  }
@@ -45,7 +49,7 @@ delete_alias() {
45
49
  for link in "$rvm_rubies_path/$alias_name" ; do
46
50
  if [[ -L "$link" ]] ; then \rm -f $link ; fi
47
51
  done
48
- $rvm_scripts_path/db "$rvm_config_path/alias" "$alias_name" "delete"
52
+ "$rvm_scripts_path"/db "$rvm_config_path/alias" "$alias_name" "delete"
49
53
  }
50
54
 
51
55
  create_alias() {
@@ -54,7 +58,7 @@ create_alias() {
54
58
  alias_name=""
55
59
  fi
56
60
  if [[ -z "$rvm_environment_identifier" ]] || [[ -z "$alias_name" ]] ; then
57
- $rvm_scripts_path/log "error" "usage: 'rvm alias [alias_name] [ruby_string]'"
61
+ "$rvm_scripts_path"/log "error" "usage: 'rvm alias [alias_name] [ruby_string]'"
58
62
  result=1
59
63
  else
60
64
  if [[ -z "$rvm_alias" ]] ; then
@@ -67,21 +71,21 @@ create_alias() {
67
71
  rvm_ruby_string="$rvm_environment_identifier"
68
72
  fi
69
73
  if [[ -z "$rvm_ruby_string" ]]; then
70
- $rvm_scripts_path/log "error" "unknown ruby string specified"
74
+ "$rvm_scripts_path"/log "error" "unknown ruby string specified"
71
75
  result=1
72
76
  return
73
77
  fi
74
78
  final_environment_identifier="$(__rvm_environment_identifier)"
75
- $rvm_scripts_path/log "info" "Creating alias $alias_name for $final_environment_identifier."
79
+ "$rvm_scripts_path"/log "info" "Creating alias $alias_name for $final_environment_identifier."
76
80
  ln -nfs "$rvm_rubies_path/$rvm_ruby_string" "$rvm_rubies_path/$alias_name"
77
- $rvm_scripts_path/log "info" "Recording alias $alias_name for $final_environment_identifier."
78
- $rvm_scripts_path/db "$rvm_config_path/alias" "$alias_name" "$final_environment_identifier"
81
+ "$rvm_scripts_path"/log "info" "Recording alias $alias_name for $final_environment_identifier."
82
+ "$rvm_scripts_path"/db "$rvm_config_path/alias" "$alias_name" "$final_environment_identifier"
79
83
  else
80
84
  if [[ -d "$rvm_rubies_path/$alias_name" ]] ; then
81
- $rvm_scripts_path/log "error" "$rvm_rubies_path/$alias_name is taken and is *not* able to be an alias name."
85
+ "$rvm_scripts_path"/log "error" "$rvm_rubies_path/$alias_name is taken and is *not* able to be an alias name."
82
86
  result=1
83
87
  else
84
- $rvm_scripts_path/log "error" "$rvm_rubies_path/$alias_name is already aliased."
88
+ "$rvm_scripts_path"/log "error" "$rvm_rubies_path/$alias_name is already aliased."
85
89
  result=1
86
90
  fi
87
91
  fi
@@ -91,7 +95,7 @@ create_alias() {
91
95
  alias_list() {
92
96
  for item in $rvm_rubies_path/* ; do
93
97
  if [[ -L "$item" ]] ; then
94
- echo "$(basename $item) => $($rvm_scripts_path/db "$rvm_config_path/alias" "$(basename "$item")")"
98
+ echo "$(basename "$item") => $("$rvm_scripts_path"/db "$rvm_config_path/alias" "$(basename "$item")")"
95
99
  fi
96
100
  done; unset item
97
101
  }
@@ -100,8 +104,12 @@ action="$1"
100
104
  alias_name="$2"
101
105
  rvm_environment_identifier="$3"
102
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
+ gemset_name="${alias_name/*${rvm_gemset_separator}/}"
109
+ alias_name="${alias_name/${rvm_gemset_separator}*/}"
110
+ fi
103
111
  if [[ ! -z "$alias_name" ]] ; then
104
- rvm_alias="$($rvm_scripts_path/db "$rvm_config_path/alias" "$alias_name")"
112
+ rvm_alias="$("$rvm_scripts_path"/db "$rvm_config_path/alias" "$alias_name")"
105
113
  fi
106
114
 
107
115
  # CLI API:
@@ -118,7 +126,7 @@ elif [[ "$action" = "list" ]] ; then
118
126
  elif [[ "$action" = "show" ]]; then
119
127
  show_alias
120
128
  else
121
- $rvm_scripts_path/log "error" "usage: 'rvm alias [action] [arguments]"
129
+ "$rvm_scripts_path"/log "error" "usage: 'rvm alias [action] [arguments]"
122
130
  fi
123
131
 
124
132
  unset action alias_name rvm_ruby_string rvm_environment_identifier final_environment_identifier
@@ -5,7 +5,7 @@
5
5
  # Use rvm_base_except="" to override the except.
6
6
  for script_name in initialize utility selector; do
7
7
  if echo "$rvm_base_except" | \grep -vq "$script_name" ; then
8
- source $rvm_scripts_path/$script_name
8
+ source "$rvm_scripts_path"/$script_name
9
9
  fi
10
10
  done; unset script_name rvm_base_except
11
11
 
@@ -12,7 +12,7 @@ cleanup() {
12
12
  for cleanup_type in $1; do
13
13
  eval "current_path=\"\$rvm_${cleanup_type}_path\""
14
14
  if [[ -n "$current_path" && -d "$current_path" && "$current_path" != "/" ]]; then
15
- $rvm_scripts_path/log "info" "Cleaning up rvm directory '$current_path'"
15
+ "$rvm_scripts_path"/log "info" "Cleaning up rvm directory '$current_path'"
16
16
  \rm -rf "$current_path"/* >/dev/null 2>&1
17
17
  fi
18
18
  done; unset cleanup_type current_path
@@ -9,7 +9,6 @@ __rvm_run_script() {
9
9
  }
10
10
 
11
11
  __rvm_parse_args() {
12
-
13
12
  # TODO:
14
13
  # Make this more robust '__rvm_history' so that it stores *unique* rvm commands.
15
14
  # Otherwise this file gets big rather fast.
@@ -51,13 +50,13 @@ __rvm_parse_args() {
51
50
  ;;
52
51
 
53
52
  # Can likely remove this due to the *) case
54
- jruby|ree|macruby|rbx|rubinius|mput|shyouhei|ironruby|default|maglev|all)
53
+ jruby*|ree*|macruby*|rbx*|rubinius*|mput*|shyouhei*|ironruby*|default*|maglev*|all)
55
54
  if [[ "rubinius" = "$rvm_token" ]] ; then rvm_token="rbx"; fi
56
55
  rvm_ruby_interpreter="$rvm_token"
57
56
  rvm_ruby_string="$rvm_token"
58
57
  rvm_ruby_strings="$rvm_token"
59
58
  rvm_action="${rvm_action:-use}"
60
- if $rvm_scripts_path/match "$1" "^[0-9]\.[0-9]" ; then rvm_ruby_version=$1 ; shift ; fi
59
+ if "$rvm_scripts_path"/match "$1" "^[0-9]\.[0-9]" ; then rvm_ruby_version=$1 ; shift ; fi
61
60
  ;;
62
61
 
63
62
  gemset)
@@ -84,9 +83,9 @@ __rvm_parse_args() {
84
83
  rvm_delete_flag=1
85
84
  rvm_ruby_args="$@" ; shift
86
85
  rvm_gemset_name="$1"; shift
87
- if [[ ! -z "$(echo $rvm_gemset_name | \grep $rvm_gemset_separator)" ]] ; then
88
- rvm_ruby_string=$(echo $rvm_gemset_name | sed 's/\(.*\)'${rvm_gemset_separator}'.*/\1/')
89
- rvm_gemset_name=$(echo $rvm_gemset_name | sed 's/.*'${rvm_gemset_separator}'\(.*\)/\1/')
86
+ if echo "$rvm_gemset_name" | \grep -q "$rvm_gemset_separator" ; then
87
+ rvm_ruby_string=$(echo "$rvm_gemset_name" | sed 's/\(.*\)'${rvm_gemset_separator}'.*/\1/')
88
+ rvm_gemset_name=$(echo "$rvm_gemset_name" | sed 's/.*'${rvm_gemset_separator}'\(.*\)/\1/')
90
89
  if [[ "$rvm_ruby_string" != "$rvm_gemset_name" ]] ; then
91
90
  rvm_ruby_string="$rvm_ruby_string${rvm_gemset_separator}$rvm_gemset_name"
92
91
  fi
@@ -103,7 +102,7 @@ __rvm_parse_args() {
103
102
  rvm_action=$rvm_token
104
103
  rvm_gemdir_flag=1
105
104
  if [[ "system" = "$1" ]] ; then rvm_system_flag=1 ; shift ; fi
106
- if [[ "user" = "$1" ]] ; then rvm_user_flag=1 ; shift ; fi
105
+ if [[ "user" = "$1" ]] ; then rvm_user_flag=1 ; shift ; fi
107
106
  ;;
108
107
 
109
108
  inspect|list|info)
@@ -151,7 +150,7 @@ __rvm_parse_args() {
151
150
  rvm_action="error"
152
151
  rvm_error_message="'rvm $rvm_action' must be followed by arguments."
153
152
  elif [[ "ruby" = "$rvm_action" ]] ; then
154
- if [[ -z "$(echo "$rvm_ruby_strings" | awk '/,/')" ]] ; then
153
+ if echo "$rvm_ruby_strings" | \grep -q ',' ; then
155
154
  rvm_action="ruby"
156
155
  rvm_ruby_args=""
157
156
  else
@@ -172,14 +171,14 @@ __rvm_parse_args() {
172
171
  rvm_parse_break=1
173
172
  fi
174
173
  else
175
- if $rvm_scripts_path/match "$1" "^-" ; then
174
+ if "$rvm_scripts_path"/match "$1" "^-" ; then
176
175
  unset rvm_ruby_strings
177
176
  else
178
- if $rvm_scripts_path/match "$1" "^[0-9]" ; then
179
- rvm_ruby_strings=$(echo "$1" | \tr ',' ' ') ; shift
177
+ if "$rvm_scripts_path"/match "$1" "^[0-9]" ; then
178
+ rvm_ruby_strings="${1//,/ }" ; shift
180
179
  unset rvm_ruby_interpreter
181
180
  else
182
- if $rvm_scripts_path/match "ruby rbx jruby macruby ree rubinius maglev mput shyouhei ironruby" "$1" ; then
181
+ if [[ "ruby rbx jruby macruby ree rubinius maglev mput shyouhei ironruby" =~ $1 ]] ; then
183
182
  rvm_ruby_strings=$1
184
183
  rvm_ruby_interpreter=$1
185
184
  shift
@@ -197,7 +196,7 @@ __rvm_parse_args() {
197
196
 
198
197
  specs|tests)
199
198
  rvm_action="rake"
200
- rvm_ruby_args="$(echo $rvm_token | sed 's/s$//')"
199
+ rvm_ruby_args="$(echo $rvm_token | sed -e 's/s$//')"
201
200
  ;;
202
201
 
203
202
  -v|--version)
@@ -215,7 +214,7 @@ __rvm_parse_args() {
215
214
 
216
215
  --ree-options)
217
216
  if [[ ! -z "$1" ]] ; then
218
- export rvm_ree_options="$(echo $1 | \tr ',' ' ')" ; shift
217
+ export rvm_ree_options="${1//,/ }" ; shift
219
218
  else
220
219
  rvm_action="error"
221
220
  rvm_error_message="--ree-options *must* be followed by... well... options."
@@ -277,13 +276,13 @@ __rvm_parse_args() {
277
276
 
278
277
  --alias)
279
278
  if [[ -n "$1" ]]; then
280
- export rvm_ruby_aliases="$(echo "$rvm_ruby_aliases $1" | \tr ',' ' ' | __rvm_strip)"
279
+ rvm_ruby_aliases="$(echo "${rvm_ruby_aliases//,/ } ${1//,/ }" | __rvm_strip)"
281
280
  shift
282
281
  fi
283
282
  ;;
284
283
 
285
284
  --symlink)
286
- $rvm_scripts_path/log "warn" "--symlink has been removed, please see 'rvm wrapper'."
285
+ "$rvm_scripts_path/log" "warn" "--symlink has been removed, please see 'rvm wrapper'."
287
286
  shift
288
287
  ;;
289
288
 
@@ -297,27 +296,29 @@ __rvm_parse_args() {
297
296
  rvm_parse_break=1
298
297
  ;;
299
298
 
300
- -h|--help|usage) rvm_action=help ;;
301
299
  -G) path_variable="rvm_gems_path" ; __rvm_set_path_variable "$1"; shift ;;
302
300
  --source) path_variable="rvm_src_path" ; __rvm_set_path_variable "$1"; shift ;;
303
301
  --archives) path_variable="rvm_archives_path" ; __rvm_set_path_variable "$1"; shift ;;
304
- --make) rvm_ruby_make="$1" ; shift ;;
305
- --make-install) rvm_ruby_make_install="$1" ; shift ;;
306
- --nice) rvm_niceness="$1" ; shift ;;
307
- -l|--level) rvm_ruby_patch_level="p$1" ; shift ;;
302
+ -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 ;;
308
307
  # TODO: handle this below better (if $1 is null)
309
- --sdk) rvm_sdk="$1" ; shift ;;
310
- --archflags) rvm_archflags="$1" ; shift ;;
311
- --install) rvm_install_on_use_flag=1 ;;
312
- --trace) rvm_trace_flag=1 ; set -x ;;
313
- --proxy) rvm_proxy="$1" ; shift ;;
314
- --disable-llvm|--disable-jit) rvm_llvm_flag=0 ;;
315
- --enable-llvm|--enable-jit) rvm_llvm_flag=1 ;;
308
+ --sdk) rvm_sdk="$1" ; shift ;;
309
+ --archflags) rvm_archflags="$1" ; shift ;;
310
+ --install) rvm_install_on_use_flag=1 ;;
311
+ --trace) rvm_trace_flag=1 ; set -x ;;
312
+ -q|--quiet) rvm_quiet_flag=1 ;;
313
+ -s|--silent) rvm_silent_flag=1 ;;
314
+ --proxy) rvm_proxy="$1" ; shift ;;
315
+ --disable-llvm|--disable-jit) rvm_llvm_flag=0 ;;
316
+ --enable-llvm|--enable-jit) rvm_llvm_flag=1 ;;
316
317
 
317
318
  reboot|damnit|wtf|argh|BOOM|boom|wth) $rvm_action="reboot" ;;
318
319
 
319
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)
320
- export rvm_$(echo $rvm_token | sed 's#-##g')_flag=1
321
+ export "rvm_${rvm_token//-/}_flag"=1
321
322
  ;;
322
323
 
323
324
  --dump-environment)
@@ -355,19 +356,10 @@ __rvm_parse_args() {
355
356
  fi
356
357
  ;;
357
358
 
358
- --with-*)
359
- rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token"
360
- ;;
361
- --without-*)
362
- rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token"
363
- ;;
364
- --enable-*)
365
- rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token"
366
- ;;
367
- --disable-*)
368
- rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token"
369
- ;;
370
-
359
+ --with-*) rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token" ;;
360
+ --without-*) rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token" ;;
361
+ --enable-*) rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token" ;;
362
+ --disable-*) rvm_ruby_configure_flags="$rvm_ruby_configure_flags $rvm_token" ;;
371
363
 
372
364
  -I|--include)
373
365
  if [[ -z "$1" ]] ; then
@@ -384,42 +376,43 @@ __rvm_parse_args() {
384
376
  *)
385
377
  if [[ -n "$rvm_token" ]] ; then
386
378
  if [[ "gemset" = "$rvm_action" ]] ; then
387
- if $rvm_scripts_path/match "$rvm_token" "^.+${rvm_gemset_separator}.+$" ; then
388
- rvm_gemset_name="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $2}')"
389
- rvm_ruby_string="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $1}')"
390
- elif [[ ! -z "$(echo "$rvm_token" | awk '/\.gems$/')" ]] ; then
391
- rvm_file_name="$(echo "$rvm_token" | sed 's#\.gems##g').gems"
379
+ if "$rvm_scripts_path/match" "$rvm_token" "^.+${rvm_gemset_separator}.+$" ; then
380
+ rvm_gemset_name="${rvm_token/*${rvm_gemset_separator}/}"
381
+ rvm_ruby_string="${rvm_token/${rvm_gemset_separator}*/}"
382
+ elif echo "$rvm_token" | \grep -q '.gems$' ; then
383
+ rvm_file_name="${rvm_token/.gems/}.gems" # Account for possible .gems.gems
392
384
  # elif [[ ! -z "$(echo "$rvm_token" | awk '/\.gems$/')" ]] ; then
393
385
  else
394
- rvm_gemset_name="$(echo "$rvm_token" | sed 's#\.gems##g')"
386
+ rvm_gemset_name="${rvm_token/.gems/}"
395
387
  rvm_file_name="$rvm_gemset_name.gems"
396
388
  fi
397
- elif [[ ! -z "$(echo "$rvm_token" | awk '/,/')" ]] ; then
389
+ elif echo "$rvm_token" | \grep -q ',' ; then
398
390
  rvm_ruby_strings="$rvm_token"
399
391
  if [[ -z "$rvm_action" ]] ; then
400
392
  rvm_action="ruby" # Not sure if we really want to do this but we'll try it out.
401
393
  fi
402
- elif $rvm_scripts_path/match "$rvm_token" "^${rvm_gemset_separator}" ; then
394
+ elif "$rvm_scripts_path/match" "$rvm_token" "^${rvm_gemset_separator}" ; then
403
395
  rvm_action="use"
404
396
  rvm_gemset_name="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $2}')"
397
+ rvm_gemset_name="${rvm_token/*${rvm_gemset_separator}/}"
405
398
  rvm_ruby_string="$(__rvm_environment_identifier | awk -F${rvm_gemset_separator} '{print $1}')"
406
399
  rvm_ruby_strings="${rvm_ruby_string}${rvm_gemset_separator}${rvm_gemset_name}"
407
- elif $rvm_scripts_path/match "$rvm_token" "^.+${rvm_gemset_separator}.+$" ; then
400
+ elif "$rvm_scripts_path/match" "$rvm_token" "^.+${rvm_gemset_separator}.+$" ; then
408
401
  rvm_gemset_name="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $2}')"
409
402
  rvm_ruby_string="$(echo "$rvm_token" | awk -F${rvm_gemset_separator} '{print $1}')"
410
403
  rvm_ruby_strings="$rvm_token"
411
- elif $rvm_scripts_path/match "$rvm_token" "^.+\\+.+$" ; then
412
- rvm_ruby_alias="$(echo "$rvm_token" | awk -F+ '{print $2}')"
413
- rvm_ruby_string="$(echo "$rvm_token" | awk -F+ '{print $1}')"
404
+ elif "$rvm_scripts_path/match" "$rvm_token" "^.+\\+.+$" ; then
405
+ rvm_ruby_alias="${rvm_token/*+/}"
406
+ rvm_ruby_string="${rvm_token/+*/}"
414
407
  rvm_ruby_strings="$rvm_ruby_string"
415
- elif $rvm_scripts_path/match "$rvm_token" "-" ; then
408
+ elif "$rvm_scripts_path/match" "$rvm_token" "-" ; then
416
409
  rvm_ruby_string="$rvm_token"
417
410
  rvm_ruby_strings="$rvm_token"
418
- elif $rvm_scripts_path/match "$rvm_token" "^[0-9].[0-9]" ; then
411
+ elif "$rvm_scripts_path/match" "$rvm_token" "^[0-9].[0-9]" ; then
419
412
  rvm_ruby_string="$rvm_token"
420
413
  rvm_ruby_strings="$rvm_token"
421
414
  rvm_action="${rvm_action:-use}"
422
- elif $rvm_scripts_path/match "$rvm_token" "^ree-" ; then
415
+ elif "$rvm_scripts_path/match" "$rvm_token" "^ree-" ; then
423
416
  rvm_ruby_string="$rvm_token"
424
417
  rvm_ruby_strings="$rvm_token"
425
418
  rvm_action="${rvm_action:-use}"
@@ -428,12 +421,10 @@ __rvm_parse_args() {
428
421
  rvm_ruby_strings="$rvm_token"
429
422
  rvm_action="${rvm_action:-use}"
430
423
  else
431
- if $rvm_scripts_path/match "$rvm_token" "\.rb$" ; then # we have a specified ruby script
424
+ if "$rvm_scripts_path/match" "$rvm_token" ".rb$" ; then # we have a specified ruby script
432
425
  rvm_ruby_args=$rvm_token
433
426
  rvm_ruby_file=$rvm_token
434
- if [[ -z "$rvm_action" ]] ; then
435
- rvm_action="ruby"
436
- fi
427
+ if [[ -z "$rvm_action" ]] ; then rvm_action="ruby" ; fi
437
428
  else
438
429
  rvm_action="error"
439
430
  rvm_error_message="Unrecognized command line argument: '$rvm_token'"
@@ -460,8 +451,8 @@ __rvm_parse_args() {
460
451
  rvm() {
461
452
  __rvm_setup
462
453
 
463
- case $- in *i*) rvm_interactive=1 ;;
464
- *) unset rvm_interactive ;;
454
+ case $- in *i*) rvm_interactive=1 ;;
455
+ *) unset rvm_interactive ;;
465
456
  esac ; export rvm_interactive
466
457
 
467
458
  if [[ -z "$ZSH_VERSION" ]] ; then
@@ -475,12 +466,13 @@ rvm() {
475
466
  return 1
476
467
  fi
477
468
 
478
- __rvm_cleanup_variables
469
+ __rvm_cleanse_variables
479
470
  __rvm_load_rvmrc
480
471
  __rvm_initialize
481
472
  __rvm_parse_args "$@"
473
+
482
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
483
- 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
475
+ 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
484
476
 
485
477
  result=0
486
478
 
@@ -497,44 +489,38 @@ rvm() {
497
489
  inspect) __rvm_inspect ; result=$? ;;
498
490
  implode|seppuku) __rvm_implode ; result=$? ;;
499
491
 
500
- list) $rvm_scripts_path/list $rvm_ruby_args ; result=$? ;;
492
+ list) "$rvm_scripts_path"/list $rvm_ruby_args ; result=$? ;;
501
493
  # TODO: Make debug run in the current environment.
502
- debug) $rvm_scripts_path/info '' debug ; result=$? ;;
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=$? ;;
503
497
  info)
504
- if [[ "$1" == "info" ]]; then shift; fi
498
+ if [[ "$1" = "info" ]]; then shift; fi
505
499
  if [[ -z "$rvm_ruby_args" ]] ; then
506
- $rvm_scripts_path/info
500
+ "$rvm_scripts_path/info"
507
501
  else
508
- $rvm_scripts_path/info $rvm_ruby_args
502
+ "$rvm_scripts_path/info" $rvm_ruby_args
509
503
  fi
510
504
  result=$?
511
505
  ;;
512
- help) $rvm_scripts_path/help $rvm_ruby_args ; result=$? ;;
513
506
 
514
- answer) __rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything ; result=42 ;;
507
+ answer) __rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything ; result=42 ;;
515
508
  question) __rvm_ultimate_question ; result=42 ;;
516
509
 
517
- env)
518
- $rvm_scripts_path/env "$rvm_ruby_string"
519
- result=$?
520
- ;;
521
-
522
510
  wrapper)
523
- $rvm_scripts_path/wrapper "$rvm_ruby_string" "$rvm_wrapper_name" $rvm_ruby_args
524
- result=$?
525
- unset rvm_wrapper_name
511
+ "$rvm_scripts_path/wrapper" "$rvm_ruby_string" "$rvm_wrapper_name" $rvm_ruby_args
512
+ result=$? ; unset rvm_wrapper_name
526
513
  ;;
527
514
 
528
515
  gemdir|gemhome|gempath)
529
- $rvm_scripts_path/gemsets "$rvm_action"
530
- result=$?
516
+ "$rvm_scripts_path/gemsets" "$rvm_action" ; result=$?
531
517
  ;;
532
518
 
533
519
  ruby|gem|rake|exec)
534
520
  old_rvm_ruby_string=$rvm_ruby_string
535
521
  unset rvm_ruby_string
536
522
  export rvm_ruby_strings
537
- $rvm_scripts_path/set $rvm_action $rvm_ruby_args
523
+ "$rvm_scripts_path/set" "$rvm_action" "$rvm_ruby_args"
538
524
  result=$?
539
525
  # Restore the state pre-sets.
540
526
  [[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string
@@ -542,17 +528,13 @@ rvm() {
542
528
  ;;
543
529
 
544
530
  cleanup|tools|snapshot|disk-usage|repair|alias|docs|rubygems|migrate|upgrade)
545
- __rvm_run_script "$rvm_action"
546
- result=$?
531
+ __rvm_run_script "$rvm_action" ; result=$?
547
532
  ;;
548
533
 
549
- rvmrc)
550
- eval "__rvm_rvmrc_tools $rvm_ruby_args"
551
- result="$?"
552
- ;;
534
+ rvmrc) eval "__rvm_rvmrc_tools $rvm_ruby_args" ; result="$?" ;;
553
535
 
554
536
  gemset)
555
- #if $rvm_scripts_path/match $rvm_ruby_args use ; then
537
+ #if "$rvm_scripts_path/match" $rvm_ruby_args use ; then
556
538
  if [[ "$rvm_use_flag" -eq 1 ]] ; then
557
539
  __rvm_gemset_select
558
540
  result=$? ; if [[ $result -eq 0 ]] ; then
@@ -560,7 +542,7 @@ rvm() {
560
542
  fi
561
543
  else
562
544
  export rvm_ruby_strings
563
- $rvm_scripts_path/gemsets $rvm_ruby_args
545
+ "$rvm_scripts_path"/gemsets $rvm_ruby_args
564
546
  unset rvm_ruby_strings
565
547
 
566
548
  # Clear the gemset.
@@ -580,35 +562,32 @@ rvm() {
580
562
 
581
563
  monitor)
582
564
  export rvm_ruby_strings rvm_ruby_string
583
- $rvm_scripts_path/monitor ; result=$?
565
+ "$rvm_scripts_path"/monitor ; result=$?
584
566
  ;;
585
- notes) $rvm_scripts_path/notes ; result=$? ;;
586
- reload) unset rvm_loaded_flag ; rvm_reload_flag=1 ;;
567
+
568
+ notes) "$rvm_scripts_path"/notes ; result=$? ;;
569
+ reload) unset rvm_loaded_flag ; rvm_reload_flag=1 ;;
570
+ tests|specs) rvm_action="rake" ; __rvm_do ; result=$? ;;
571
+ package) "$rvm_scripts_path"/package $rvm_ruby_args ; result=$? ;;
587
572
 
588
573
  fetch|install|uninstall|remove)
589
574
  if [[ -n "$rvm_ruby_strings" ]]; then
590
- $rvm_scripts_path/manage "$rvm_action" "$rvm_ruby_strings"
575
+ "$rvm_scripts_path"/manage "$rvm_action" "$rvm_ruby_strings"
591
576
  else
592
- $rvm_scripts_path/manage "$rvm_action"
577
+ "$rvm_scripts_path"/manage "$rvm_action"
593
578
  fi
594
579
  result=$?
595
580
  ;;
596
- tests|specs) rvm_action="rake" ; __rvm_do ; result=$? ;;
597
-
598
- package)
599
- $rvm_scripts_path/package $rvm_ruby_args
600
- result=$?
601
- ;;
602
581
 
603
582
  error)
604
- $rvm_scripts_path/log "fail" "$rvm_error_message ( see: 'rvm usage' )"
583
+ "$rvm_scripts_path"/log "fail" "$rvm_error_message ( see: 'rvm usage' )"
605
584
  __rvm_pushpop
606
585
  result=1
607
586
  ;;
608
587
 
609
588
  *)
610
589
  if [[ ! -z "$rvm_action" ]] ; then
611
- $rvm_scripts_path/log "fail" "unknown action '$rvm_action'"
590
+ "$rvm_scripts_path/log" "fail" "unknown action '$rvm_action'"
612
591
  else
613
592
  __rvm_usage
614
593
  fi