rvm 0.0.61 → 0.0.62

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/completion CHANGED
@@ -6,8 +6,8 @@ _rvm ()
6
6
  {
7
7
  local i c=1 command __git_dir
8
8
 
9
- while [ $c -lt $COMP_CWORD ]; do
10
- i="${COMP_WORDS[c]}"
9
+ while [[ $c -lt $COMP_CWORD ]]; do
10
+ i="${COMP_WORDS[[c]]}"
11
11
  case "$i" in
12
12
  --git-dir=*) __git_dir="${i#--git-dir=}" ;;
13
13
  --bare) __git_dir="." ;;
@@ -18,8 +18,8 @@ _rvm ()
18
18
  c=$((++c))
19
19
  done
20
20
 
21
- if [ -z "$command" ]; then
22
- case "${COMP_WORDS[COMP_CWORD]}" in
21
+ if [[ -z "$command" ]]; then
22
+ case "${COMP_WORDS[[COMP_CWORD]]}" in
23
23
  --*) __gitcomp "
24
24
  --paginate
25
25
  --no-pager
@@ -38,7 +38,7 @@ _rvm ()
38
38
  fi
39
39
 
40
40
  local expansion=$(__git_aliased_command "$command")
41
- [ "$expansion" ] && command="$expansion"
41
+ [[ "$expansion" ]] && command="$expansion"
42
42
 
43
43
  case "$command" in
44
44
  install|uninstall|path|info|setup|version|srcdir|list|reset|debug|reload|usage|help|implode|update|readline|iconv|benchmark|bench|use|gemsync)
@@ -110,8 +110,8 @@ _rvm ()
110
110
  # generates completion reply with compgen
111
111
  function __rvm_completion_reply
112
112
  {
113
- local cur="${COMP_WORDS[COMP_CWORD]}"
114
- if [ $# -gt 2 ]; then
113
+ local cur="${COMP_WORDS[[COMP_CWORD]]}"
114
+ if [[ $# -gt 2 ]]; then
115
115
  cur="$3"
116
116
  fi
117
117
  case "$cur" in
@@ -173,7 +173,7 @@ function _rvm {
173
173
  info|debug)
174
174
  __rvm_version
175
175
  __rvm_info
176
- if [ "debug" = "$rvm_action" ] ; then __rvm_debug ; fi
176
+ if [[ "debug" = "$rvm_action" ]] ; then __rvm_debug ; fi
177
177
  result=0
178
178
  ;;
179
179
 
@@ -183,7 +183,7 @@ function _rvm {
183
183
  result=1;
184
184
  ;;
185
185
  *)
186
- if [ ! -z "$rvm_action" ] ; then
186
+ if [[ ! -z "$rvm_action" ]] ; then
187
187
  __rvm_log "fail" "unknown action '$rvm_action'"
188
188
  else
189
189
  __rvm_usage
data/scripts/gems CHANGED
@@ -2,52 +2,52 @@
2
2
 
3
3
  __rvm_gems() {
4
4
  unset GEM_PATH
5
- if [ -z "$rvm_ruby_selected_flag" ] ; then __rvm_select $* ; fi
5
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
6
6
 
7
- if [ ! -z "$rvm_clear_flag" ] ; then
7
+ if [[ ! -z "$rvm_clear_flag" ]] ; then
8
8
  __rvm_gems_clear
9
- elif [ ! -z "$rvm_load_flag" ] ; then
9
+ elif [[ ! -z "$rvm_load_flag" ]] ; then
10
10
  __rvm_gems_load
11
- elif [ ! -z "$rvm_dump_flag" ] ; then
11
+ elif [[ ! -z "$rvm_dump_flag" ]] ; then
12
12
  __rvm_gems_dump
13
- elif [ ! -z "$rvm_delete_flag" ] ; then
13
+ elif [[ ! -z "$rvm_delete_flag" ]] ; then
14
14
  __rvm_gems_delete
15
- elif [ ! -z "$rvm_name_flag" ] ; then
15
+ elif [[ ! -z "$rvm_name_flag" ]] ; then
16
16
  __rvm_gems_name
17
- elif [ ! -z "$rvm_dir_flag" ] ; then
17
+ elif [[ ! -z "$rvm_dir_flag" ]] ; then
18
18
  __rvm_gems_dir
19
- elif [ ! -z "$rvm_list_flag" ] ; then
19
+ elif [[ ! -z "$rvm_list_flag" ]] ; then
20
20
  __rvm_gems_list
21
- #elif [ ! -z "$rvm_use_flag" ] ; then
21
+ #elif [[ ! -z "$rvm_use_flag" ]] ; then
22
22
  else
23
23
  __rvm_gems_use
24
24
  fi
25
25
  }
26
26
 
27
27
  __rvm_gems_select() {
28
- if [ -z "$rvm_gem_set_name" ] ; then
29
- if [ ! -z "$GEM_HOME" ] ; then
28
+ if [[ -z "$rvm_gem_set_name" ]] ; then
29
+ if [[ ! -z "$GEM_HOME" ]] ; then
30
30
  rvm_gem_set_name=$(echo $GEM_HOME | xargs basename | awk -F'%' '{print $2}')
31
31
  fi
32
32
 
33
- if [ ! -z "$rvm_ruby_gem_home" ] ; then
33
+ if [[ ! -z "$rvm_ruby_gem_home" ]] ; then
34
34
  rvm_gem_set_name=$(echo $rvm_ruby_gem_home | xargs basename | awk -F'%' '{print $2}')
35
35
  fi
36
36
 
37
37
  if [[ ! -z "$rvm_gem_set_name" ]] && [[ ! "$rvm_gem_set_name" =~ ^\d\.\d ]] ; then
38
38
  rvm_ruby_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version%$rvm_gem_set_name"
39
39
  else
40
- if [ ! -z "$rvm_ruby_interpreter" -a ! -z "$rvm_ruby_version" -a "$rvm_ruby_interpreter" != "system" ] ; then
40
+ if [[ ! -z "$rvm_ruby_interpreter" ]] && [[ ! -z "$rvm_ruby_version" ]] && [[ "$rvm_ruby_interpreter" != "system" ]] ; then
41
41
  rvm_ruby_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version"
42
- elif [ -z "$GEM_HOME" ] ; then
42
+ elif [[ -z "$GEM_HOME" ]] ; then
43
43
  rvm_ruby_gem_home=$(gem env gemdir)
44
- elif [ ! -z "$GEM_HOME" ] ; then
44
+ elif [[ ! -z "$GEM_HOME" ]] ; then
45
45
  rvm_ruby_gem_home="$GEM_HOME"
46
46
  else
47
47
  __rvm_log "error" "Cannot select gem home, something definitely wrong :/"
48
48
  fi
49
49
  fi
50
- if [ -z "$rvm_gem_set_name" ] ; then unset rvm_gem_set_name ; fi
50
+ if [[ -z "$rvm_gem_set_name" ]] ; then unset rvm_gem_set_name ; fi
51
51
  else
52
52
  rvm_ruby_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version%$rvm_gem_set_name"
53
53
  fi
@@ -80,16 +80,16 @@ __rvm_gems_clear() {
80
80
  __rvm_gems_use
81
81
  }
82
82
 
83
- __rvm_gems_delete () {
84
- if [ ! -z "$rvm_gem_set_name" ] ; then
83
+ __rvm_gems_delete() {
84
+ if [[ ! -z "$rvm_gem_set_name" ]] ; then
85
85
  gemdir="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version%$rvm_gem_set_name"
86
- if [ -d "$gemdir" -a ! -z "$rvm_force_flag" ] ; then
86
+ if [[ -d "$gemdir" ]] && [[ ! -z "$rvm_force_flag" ]] ; then
87
87
  rm -rf "$gemdir"
88
- elif [ -d "$gemdir" ] ; then
88
+ elif [[ -d "$gemdir" ]] ; then
89
89
  __rvm_log "warn" "Are you SURE you wish to remove the installed gems '$rvm_gem_set_name ' ($gemdir)?"
90
90
  echo -n "(anything other than 'yes' will cancel) > "
91
91
  read response
92
- if [ "yes" = "$response" ] ; then
92
+ if [[ "yes" = "$response" ]] ; then
93
93
  rm -rf "$gemdir"
94
94
  else
95
95
  __rvm_log "info" "Not doing anything, phew... close call that one eh?"
@@ -103,13 +103,13 @@ __rvm_gems_delete () {
103
103
  }
104
104
 
105
105
  __rvm_gems_dump() {
106
- if [ ! -z "$rvm_ruby_gem_home" ] ; then
106
+ if [[ ! -z "$rvm_ruby_gem_home" ]] ; then
107
107
  GEM_HOME="$rvm_ruby_gem_home" ; export GEM_HOME ;
108
108
  GEM_PATH="$rvm_ruby_gem_home" ; export GEM_PATH ;
109
109
  fi
110
110
 
111
- if [ -z "$rvm_file_name" ] ; then
112
- if [ ! -z "$rvm_gem_set_name" ] ; then
111
+ if [[ -z "$rvm_file_name" ]] ; then
112
+ if [[ ! -z "$rvm_gem_set_name" ]] ; then
113
113
  rvm_file_name="$rvm_gem_set_name.gems"
114
114
  else
115
115
  rvm_file_name="default.gems"
@@ -121,7 +121,7 @@ __rvm_gems_dump() {
121
121
 
122
122
  for gem in $(gem list | sed 's#[\(|\)]##g' | sed 's#, #,#g' | tr ' ' ';') ; do
123
123
  name="$(echo $gem | awk -F';' '{print $1}')"
124
- if [ -z "$rvm_latest_flag" ] ; then
124
+ if [[ -z "$rvm_latest_flag" ]] ; then
125
125
  versions="$(echo $gem | awk -F';' '{print $2}' | sed 's#,# #g')"
126
126
  for version in $versions ; do
127
127
  echo "$name -v$version" >> $rvm_file_name
@@ -133,69 +133,69 @@ __rvm_gems_dump() {
133
133
  }
134
134
 
135
135
  __rvm_gems_load() {
136
- if [ ! -z "$rvm_ruby_gem_home" ] ; then
136
+ if [[ ! -z "$rvm_ruby_gem_home" ]] ; then
137
137
  GEM_HOME="$rvm_ruby_gem_home" ; export GEM_HOME ;
138
138
  GEM_PATH="$rvm_ruby_gem_home" ; export GEM_PATH ;
139
139
  fi
140
140
 
141
- if [ -z "$rvm_file_name" ] ; then
142
- if [ -f "$rvm_gem_set_name.gems" ] ; then
141
+ if [[ -z "$rvm_file_name" ]] ; then
142
+ if [[ -f "$rvm_gem_set_name.gems" ]] ; then
143
143
  rvm_file_name="$rvm_gem_set_name.gems"
144
- elif [ -f "default.gems" ] ; then
144
+ elif [[ -f "default.gems" ]] ; then
145
145
  rvm_file_name="default.gems"
146
- elif [ -f "system.gems" ] ; then
146
+ elif [[ -f "system.gems" ]] ; then
147
147
  rvm_file_name="system.gems"
148
148
  fi
149
149
  fi
150
150
 
151
- if [ -f "$rvm_file_name" ] ; then
151
+ if [[ -f "$rvm_file_name" ]] ; then
152
152
  echo "Loading $rvm_file_name file..."
153
- rvm_ruby_gem_list=$(/bin/ls $rvm_ruby_gem_home/specifications/ 2> /dev/null | sed 's#\.gemspec$##' 2> /dev/null)
153
+ rvm_ruby_gem_list=$(/bin/ls $rvm_ruby_gem_home/specifications/ 2> /dev/null | sed 's#.gems.*$##' 2> /dev/null)
154
154
  while read line
155
155
  do # Keep this on 2nd line :( bash fail.
156
156
  # TODO: Switch to a different field separator than ; to allow for evals
157
157
  gem="$(echo $line | awk -F';' '{print $1}')"
158
+ gem_prefix="$(echo $line | awk -F';' '{print $2}')"
158
159
  if [[ ! -z "$gem" ]] && [[ "$gem" =~ \.gem$ ]] ; then
159
- gem_prefix="$(echo $line | awk -F';' '{print $2}')"
160
- gem_name="$(echo $gem | awk '{print $1}')"
161
- gem_version="$(echo $gem | awk '{print $2}' | sed 's#^.*-v[=]*[ ]*##' )"
162
- gem_postfix="$(echo $gem | sed "s/$gem_name//" | sed "s#-v[=]*[ ]*$gem_version##")"
160
+ gem_name="$(basename $gem | sed 's#\.gem##' | awk -F'-' '{$NF=NULL;print}')"
161
+ gem_version="$(basename $gem | sed 's#\.gem##' | awk -F'-' '{print $NF}' )"
162
+ gem_postfix="$(basename $gem | sed "s#.*\.gem##")"
163
163
  else
164
- gem_prefix="$(echo $line | awk -F';' '{print $2}')"
165
164
  gem_name="$(echo $gem | awk '{print $1}')"
166
- gem_version="$(echo $gem | awk '{print $2}' | sed 's#^.*-v[=]*[ ]*##' )"
167
- gem_postfix="$(echo $gem | sed "s/$gem_name//" | sed "s#-v[=]*[ ]*$gem_version##")"
165
+ gem_version="$(echo $gem | awk '{print $2}' | sed 's#.*-v[=]*[ ]*##' )"
166
+ gem_postfix="$(echo $gem | sed "s#${gem_name/ /}##" | sed "s#-v[=]*[ ]*${gem_version/ /}##")"
168
167
  fi
169
168
 
170
- if [ -f "$gem" ] ; then
171
- gem_file_name="$(basename $gem)"
169
+ if [[ -f "$gem" ]] ; then
170
+ gem_file_name="$gem"
171
+ cache_file="$gem"
172
172
  elif [[ ! -z "$gem" ]] && [[ "$gem" =~ ".gem$" ]] ; then
173
- gem_file_name="${gem}"
174
- elif [ -z "$gem_version" ] ; then # no version
175
- gem_file_name="${gem_name}*.gem"
173
+ gem_file_name="$gem"
174
+ elif [[ -z "${gem_version/ /}" ]] ; then # no version
175
+ gem_file_name="${gem_name/ /}*.gem"
176
176
  else # version
177
- gem_file_name="$gem_name-$gem_version.gem"
177
+ gem_file_name="${gem_name/ /}-${gem_version/ /}.gem"
178
178
  fi
179
179
 
180
- if [ -z "$rvm_force_flag" -a -f "$rvm_ruby_gem_home/specifications/${gem_file_name/\.gem/.gemspec}" ] ; then
180
+ if [[ -z "$rvm_force_flag" ]] && [[ -f "${rvm_ruby_gem_home}/specifications/${gem_name/ /}-${gem_version/ /}.gemspec" ]] ; then
181
181
  unset gem
182
- __rvm_log "warn" "Skipping $(__color "yellow")$gem_name $gem_version$(__color "none") (--force to re-install)"
182
+ __rvm_log "warn" "$(__color "yellow")$gem_name $gem_version$(__color "none") exists, skipping (--force to re-install)"
183
183
  else
184
- cache_file=$(/bin/ls -t "$rvm_gem_path/*/*/cache/${gem_file_name}*" 2> /dev/null | head -n1)
185
- if [ -z "$cache_file" ] ; then
186
- if [ -f "$gem_file_name" ] ; then
184
+ cache_file="${cache_file:-$(/bin/ls -t "${rvm_gem_path}/*/*/cache/${gem_file_name}*" 2> /dev/null | head -n1)}"
185
+ if [[ -z "$cache_file" ]] ; then
186
+ if [[ -f "$gem_file_name" ]] ; then
187
187
  gem="$gem_file_name"
188
- elif [ -z "$gem_version" ] ; then
189
- gem="$gem_name"
188
+ elif [[ -z "${gem_version/ /}" ]] ; then
189
+ gem="${gem_name/ /}"
190
190
  else
191
- gem="$gem_name -v $gem_version"
191
+ gem="${gem_name/ /} -v $gem_version"
192
192
  fi
193
193
  else # cached
194
- gem_file_name="$(basename $cache_file)"
194
+ gem_file_name="$(basename "$cache_file")"
195
195
  gem_string="$(echo "$gem_file_name" | sed 's#\.gem$##')"
196
- if [ ! -z "$(echo "$rvm_ruby_gem_list" | awk "/$gem_string/{print}")" ] ; then
196
+ if [[ ! -z "$(echo "$rvm_ruby_gem_list" | awk "/${gem_name/ /} \(.*$gem_version/{print}")" ]] ; then
197
197
  #if [[ ! -z "$rvm_ruby_gem_list" ]] && [[ "$rvm_ruby_gem_list" =~ $gem_string ]] ; then
198
- if [ ! -z "$rvm_force_flag" ] ; then
198
+ if [[ ! -z "$rvm_force_flag" ]] ; then
199
199
  cp $cache_file $rvm_temp_path/$gem_file_name
200
200
  gem="$rvm_temp_path/$gem_file_name" # install as a named local gem
201
201
  fi
@@ -205,7 +205,7 @@ __rvm_gems_load() {
205
205
  fi
206
206
  fi
207
207
 
208
- if [ ! -z "$gem" ] ; then
208
+ if [[ ! -z "$gem" ]] ; then
209
209
  # TODO: Set vars if fourth field is non-empty (means that there are conditional statements to execute in the gem install line.
210
210
  __rvm_make_flags
211
211
  __rvm_log "info" "Installing $gem_name $gem_version..."
data/scripts/install CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
3
  user="$(whoami)"
4
- if [ "root" = "$user" ] ; then
4
+ if [[ "root" = "$user" ]] ; then
5
5
  echo -e "$(tput setaf 1) <e> root user support is not yet implemented.$(tput sgr0)"
6
6
  exit 1
7
7
  fi
@@ -10,7 +10,7 @@ item="$(tput setaf 2)* $(tput sgr0)"
10
10
  question="\n$(tput setaf 2)<?>$(tput sgr0)"
11
11
  cwd=$(pwd)
12
12
  source_dir="${source_dir:-"$(dirname $0 | xargs dirname)"}"
13
- if [ ! -d "$source_dir" ] ; then unset source_dir ; fi
13
+ if [[ ! -d "$source_dir" ]] ; then unset source_dir ; fi
14
14
  source_dir="${source_dir:-$cwd}"
15
15
  rvm_path=~/.rvm
16
16
 
@@ -32,34 +32,34 @@ for file_name in rvm-prompt gemsync ; do
32
32
  chmod +x $rvm_path/bin/$file_name
33
33
  done ; unset file_name
34
34
 
35
- if [ -z "$rvm_loaded_flag" ] ; then
35
+ if [[ -z "$rvm_loaded_flag" ]] ; then
36
36
  for rcfile in .bash_profile .bashrc .zshrc ; do
37
- if [ ! -e ~/$rcfile ] ; then touch ~/$rcfile ; fi
38
- if [ -z "$(awk '/\.rvm\/scripts\/rvm/' ~/$rcfile)" ] ; then
39
- echo "Adding 'if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi' to your ~/$rcfile."
40
- echo -e "\n# rvm-install added line:\nif [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi\n" >> ~/$rcfile
37
+ if [[ ! -e ~/$rcfile ]] ; then touch ~/$rcfile ; fi
38
+ if [[ -z "$(awk '/\.rvm\/scripts\/rvm/' ~/$rcfile)" ]] ; then
39
+ echo "Adding 'if [[ -s ~/.rvm/scripts/rvm ]] ; then source ~/.rvm/scripts/rvm ; fi' to your ~/$rcfile."
40
+ echo -e "\n# rvm-install added line:\nif [[ -s ~/.rvm/scripts/rvm ]] ; then source ~/.rvm/scripts/rvm ; fi\n" >> ~/$rcfile
41
41
  fi
42
42
  done
43
43
  fi
44
44
 
45
45
  echo -e "\n Ensuring that rvm script location in $file is scripts/rvm not bin/rvm for: ~/.bash_profile, ~/.bashrc, ~/.zshrc..."
46
46
  for file in ~/.bash_profile ~/.bashrc ~/.zshrc ; do
47
- if [ -s $file ] ; then
48
- if [ -L $file ] ; then # If the file is a symlink,
47
+ if [[ -s $file ]] ; then
48
+ if [[ -L $file ]] ; then # If the file is a symlink,
49
49
  actual_file="$(readlink $file)" # read the link target so we can preserve it.
50
50
  else
51
51
  actual_file="$file"
52
52
  fi
53
53
 
54
54
  grep 'rvm\/bin\/rvm' $actual_file > /dev/null
55
- if [ $? -eq 0 ] ; then
55
+ if [[ $? -eq 0 ]] ; then
56
56
  sed -i.orig 's#rvm/bin/rvm #rvm/scripts/rvm #g' $actual_file
57
57
  rm -f $actual_file.orig
58
58
  fi
59
59
 
60
- if [ -f ~/.profile ] ; then
60
+ if [[ -f ~/.profile ]] ; then
61
61
  grep '.profile' $actual_file > /dev/null
62
- if [ $? -gt 0 ] ; then
62
+ if [[ $? -gt 0 ]] ; then
63
63
  profile=~/.profile
64
64
  echo -e "\n" >> $actual_file
65
65
  echo "source $profile" >> $actual_file
@@ -68,34 +68,34 @@ for file in ~/.bash_profile ~/.bashrc ~/.zshrc ; do
68
68
  fi
69
69
  done
70
70
 
71
- if [ -f ~/.rvm/bin/rvm ] ; then
71
+ if [[ -f ~/.rvm/bin/rvm ]] ; then
72
72
  echo -e "\n Removing old rvm file from ~/.rvm/bin/rvm..."
73
73
  rm -f ~/.rvm/bin/rvm
74
74
  fi
75
75
 
76
76
  system="$(uname)"
77
77
  echo -e "\n $(tput setaf 3)NOTES: $(tput sgr0)\n"
78
- if [ "Linux" = "$system" ] ; then
78
+ if [[ "Linux" = "$system" ]] ; then
79
79
  rvm_apt_get_binary="$(which aptitude 2> /dev/null)"
80
80
  rvm_emerge_binary="$(which emerge 2> /dev/null)"
81
81
  rvm_pacman_binary="$(which pacman 2> /dev/null)"
82
82
  rvm_yum_binary="$(which yum 2> /dev/null)"
83
83
 
84
- if [ ! -z "$rvm_apt_get_binary" ] ; then
84
+ if [[ ! -z "$rvm_apt_get_binary" ]] ; then
85
85
  echo -e " $item For jRuby (if you wish to use it) you will need:"
86
86
  echo -e " $ sudo aptitude install sun-java6-bin sun-java6-jre sun-java6-jdk"
87
87
  echo -e " $item For ree (if you wish to use it) you will need:"
88
88
  echo -e " $ sudo aptitude install libreadline5-dev libssl-dev bison"
89
89
 
90
- elif [ ! -z "$rvm_emerge_binary" ] ; then
90
+ elif [[ ! -z "$rvm_emerge_binary" ]] ; then
91
91
  echo -e " $item For jRuby (if you wish to use it) you will need:"
92
92
  echo -e " $ sudo emerge dev-java/sun-jdk dev-java/sun-jre-bin"
93
93
 
94
- elif [ ! -z "$rvm_pacman_binary" ] ; then
94
+ elif [[ ! -z "$rvm_pacman_binary" ]] ; then
95
95
  echo -e " $item For jRuby (if you wish to use it) you will need:"
96
96
  echo -e " $ sudo pacman -Sy jdk jre"
97
97
 
98
- elif [ ! -z "$rvm_yum_binary" ] ; then
98
+ elif [[ ! -z "$rvm_yum_binary" ]] ; then
99
99
  echo -e " $item For ree (if you wish to use it) you will need:"
100
100
  echo -e " $ yum install -y rpm-build gcc gcc-c++ redhat-rpm-config ; then download and rpmbuild and install the sdk, Have fun..."
101
101
 
@@ -103,13 +103,13 @@ if [ "Linux" = "$system" ] ; then
103
103
  echo -e " $item For jRuby (if you wish to use it) you will need:"
104
104
  echo -e " The SUN java runtime environment and development kit."
105
105
  fi
106
- elif [ "Darwin" = "$system" ] ; then
106
+ elif [[ "Darwin" = "$system" ]] ; then
107
107
  echo -e " $item Be sure that you have XCode Tools installed in order to use rvm."
108
108
  echo -e " $item If you intend on installing MacRuby you must install LLVM first."
109
109
  fi
110
110
 
111
111
  echo -e " $item In order to use rvm the following line must occur in your shell's loading files, after all path/variable settings.:"
112
- echo -e " $item if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi"
112
+ echo -e " $item if [[ -s ~/.rvm/scripts/rvm ]] ; then source ~/.rvm/scripts/rvm ; fi"
113
113
  echo -e " $item CLOSE THIS SHELL AND OPEN A NEW ONE in order to use rvm."
114
114
 
115
115
  echo -e "\n \033[0;33mRTFM: $(tput sgr0) http://rvm.beginrescueend.com/ \n"
@@ -1,50 +1,50 @@
1
1
  #!/bin/bash
2
2
 
3
3
  function __rvm_install_source {
4
- if [ -z "$rvm_ruby_selected_flag" ] ; then __rvm_select $* ; fi
4
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
5
5
  __rvm_log "info" "Installing Ruby from source to: $rvm_ruby_home"
6
6
  mkdir -p "$rvm_ruby_log_path"
7
7
 
8
8
  __rvm_pushpop "$rvm_src_path"
9
9
 
10
- if [ ! -z "$rvm_force_flag" ] ; then
10
+ if [[ ! -z "$rvm_force_flag" ]] ; then
11
11
  rm -rf "$rvm_ruby_home" "$rvm_ruby_src_path"
12
12
  fi
13
13
 
14
14
  result=0
15
- if [ -z "$rvm_ruby_tag" -a -z "$rvm_ruby_revision" ] ; then
16
- if [ ! -f "$rvm_archives_path/$rvm_ruby_package_name.tar.gz" ] ; then
15
+ if [[ -z "$rvm_ruby_tag" ]] && [[ -z "$rvm_ruby_revision" ]] ; then
16
+ if [[ ! -f "$rvm_archives_path/$rvm_ruby_package_name.tar.gz" ]] ; then
17
17
  rvm_url="${rvm_url:-"ftp://ftp.ruby-lang.org/pub/ruby/1.$rvm_major_version/$rvm_ruby_package_name.tar.gz"}"
18
18
  __rvm_log "info" "Downloading $rvm_ruby_package_name, this may take a while depending on your connection..."
19
19
  __rvm_fetch "$rvm_url"
20
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
20
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
21
21
  fi
22
22
  #mkdir -p "$rvm_ruby_src_path" # Is this line necessary considering -C below? v
23
23
  __rvm_run "extract" "tar xzf $rvm_archives_path/$rvm_ruby_package_name.tar.gz -C $rvm_src_path" "Extracting $rvm_ruby_package_name ..."
24
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
24
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
25
25
  else
26
26
  __rvm_log "info" "Retrieving Ruby from $rvm_url"
27
- if [ ! -z "$(echo $rvm_url | awk '/^git/')" ] ; then
28
- if [ -d "$rvm_ruby_src_path/.git" ] ; then
27
+ if [[ ! -z "$(echo $rvm_url | awk '/^git/')" ]] ; then
28
+ if [[ -d "$rvm_ruby_src_path/.git" ]] ; then
29
29
  cd $rvm_ruby_src_path
30
- if [ -z "$rvm_ruby_revision" ] ; then
30
+ if [[ -z "$rvm_ruby_revision" ]] ; then
31
31
  git pull origin master
32
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
32
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
33
33
  else
34
34
  git checkout ${rvm_ruby_revision:-HEAD}
35
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
35
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
36
36
  fi
37
37
  else
38
38
  git clone --depth 1 $rvm_ruby_repo_url $rvm_ruby_src_path
39
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
39
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
40
40
  fi
41
41
  else
42
- if [ -z "$rvm_ruby_revision" ] ; then
42
+ if [[ -z "$rvm_ruby_revision" ]] ; then
43
43
  # TODO: Check if tag v is valid
44
44
  rvm_url="$rvm_ruby_repo_url/tags/$rvm_ruby_tag"
45
45
  rvm_rev=""
46
46
  else
47
- if [ "head" = "$rvm_ruby_revision" -o "trunk" = "$rvm_ruby_revision" ] ; then
47
+ if [[ "head" = "$rvm_ruby_revision" ]] || [[ "trunk" = "$rvm_ruby_revision" ]] ; then
48
48
  rvm_url="$rvm_ruby_repo_url/trunk"
49
49
  rvm_rev=""
50
50
  else
@@ -53,9 +53,9 @@ function __rvm_install_source {
53
53
  fi
54
54
  fi
55
55
 
56
- if [ -d "$rvm_ruby_src_path/.svn" ] ; then
56
+ if [[ -d "$rvm_ruby_src_path/.svn" ]] ; then
57
57
  cd $rvm_ruby_src_path
58
- if [ -z "$rvm_rev" ] ; then
58
+ if [[ -z "$rvm_rev" ]] ; then
59
59
  svn update
60
60
  else
61
61
  svn checkout -q $rvm_rev
@@ -63,27 +63,27 @@ function __rvm_install_source {
63
63
  else
64
64
  svn checkout -q $rvm_rev --force $rvm_url $rvm_ruby_src_path
65
65
  fi
66
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
66
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
67
67
  fi
68
68
  fi
69
69
 
70
70
  cd $rvm_ruby_src_path
71
- if [ $? -gt 0 ] ; then result=$? ; __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; __rvm_pushpop ; return $result ; fi
71
+ if [[ $? -gt 0 ]] ; then result=$? ; __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; __rvm_pushpop ; return $result ; fi
72
72
 
73
- if [ ! -s "$rvm_ruby_src_path/configure" ] ; then
73
+ if [[ ! -s "$rvm_ruby_src_path/configure" ]] ; then
74
74
  rvm_autoconf="$(which autoconf)"
75
- if [ $? -gt 0 ] ; then __rvm_log "fail" "rvm expects autoconf" ; result=$? ; return $result ; fi
75
+ if [[ $? -gt 0 ]] ; then __rvm_log "fail" "rvm expects autoconf" ; result=$? ; return $result ; fi
76
76
  __rvm_run "autoconf" "$rvm_autoconf" "Running autoconf"
77
- # if [ $? -gt 0 ] ; then result=$? ; return $result ; fi # Don't barf on autoconf fail...
77
+ # if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi # Don't barf on autoconf fail...
78
78
  fi
79
79
 
80
- if [ -s ./Makefile -a -z "$rvm_reconfigure_flag" ] ; then
80
+ if [[ -s ./Makefile ]] && [[ -z "$rvm_reconfigure_flag" ]] ; then
81
81
  __rvm_log "debug" "Skipping configure step, Makefile exists so configure must have already been run."
82
- elif [ -s ./configure ] ; then
82
+ elif [[ -s ./configure ]] ; then
83
83
  __rvm_run "configure" "./configure --prefix=$rvm_ruby_home $rvm_ruby_configure $configure_parameters" "Configuring $rvm_ruby_package_name using $rvm_ruby_configure, this may take a while depending on your cpu(s)..."
84
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
84
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
85
85
  unset configure_parameters
86
- elif [ ! -z "rvm_ruby_configure" ] ; then
86
+ elif [[ ! -z "rvm_ruby_configure" ]] ; then
87
87
  $rvm_ruby_configure
88
88
  else
89
89
  __rvm_log "error" "Skipping configure step, 'configure' script does not exist, did autoconf not run successfully?"
@@ -91,11 +91,11 @@ function __rvm_install_source {
91
91
 
92
92
  rvm_ruby_make=${rvm_ruby_make:-"/usr/bin/make"}
93
93
  __rvm_run "make" "$rvm_ruby_make $rvm_make_flags" "Compiling $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..."
94
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
94
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
95
95
 
96
96
  rvm_ruby_make_install=${rvm_ruby_make_install:-"/usr/bin/make install"}
97
97
  __rvm_run "install" "$rvm_ruby_make_install" "Installing $rvm_ruby_package_name"
98
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
98
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
99
99
 
100
100
  __rvm_log "info" "Installation of $rvm_ruby_package_name is complete."
101
101
 
@@ -111,13 +111,13 @@ function __rvm_install_source {
111
111
 
112
112
  function __rvm_install_ruby {
113
113
 
114
- if [ -z "$rvm_ruby_selected_flag" ] ; then __rvm_select $* ; fi
115
- if [ ! -z "$RUBYOPT" ] ; then ruby_options="$RUBYOPT" ; unset RUBYOPT ; fi
114
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
115
+ if [[ ! -z "$RUBYOPT" ]] ; then ruby_options="$RUBYOPT" ; unset RUBYOPT ; fi
116
116
  __rvm_make_flags
117
117
 
118
118
  case "$rvm_ruby_interpreter" in
119
119
  macruby)
120
- if [ "$(uname)" = "Darwin" ] ; then
120
+ if [[ "$(uname)" = "Darwin" ]] ; then
121
121
  rvm_url="$(__rvm_db "macruby_nightly_url")"
122
122
  __rvm_log "info" "Retrieving latest macruby" # $rvm_archives_path/macruby_nightly.pkg
123
123
  __rvm_fetch $rvm_url
@@ -130,28 +130,29 @@ function __rvm_install_ruby {
130
130
  ;;
131
131
 
132
132
  ree)
133
- if [ ! -z "$(echo $rvm_ruby_version | awk '/^1\.8/')" -a -z "$rvm_head_flag" ] ; then
133
+ __rvm_make_flags
134
+ if [[ ! -z "$(echo $rvm_ruby_version | awk '/^1\.8/')" ]] && [[ -z "$rvm_head_flag" ]] ; then
134
135
  rvm_url="$(__rvm_db "ree_${rvm_ruby_version}_url")/$rvm_ruby_package_file.tar.gz"
135
136
  __rvm_log "info" "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home"
136
137
  __rvm_pushpop "$rvm_src_path"
137
- if [ -z "$rvm_force_flag" -a -d "$rvm_ruby_src_path" -a ! -x "$rvm_ruby_src_path/installer" ] ; then
138
+ if [[ -z "$rvm_force_flag" ]] && [[ -d "$rvm_ruby_src_path" ]] && [[ ! -x "$rvm_ruby_src_path/installer" ]] ; then
138
139
  __rvm_log "It appears that the archive has already been extracted. Skipping extract (use --force to force re-download and extract)."
139
140
  else
140
141
  __rvm_log "Downloading $rvm_ruby_package_file, this may take a while depending on your connection..."
141
142
  __rvm_fetch "$rvm_url"
142
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
143
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
143
144
  rm -rf "$rvm_ruby_src_path"
144
145
  __rvm_run "extract" "tar xzf $rvm_archives_path/$rvm_ruby_package_file.tar.gz -C $rvm_src_path" "Extracting $rvm_ruby_package_file..."
145
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
146
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
146
147
  mv "$rvm_src_path/$rvm_ruby_package_file" "$rvm_ruby_src_path"
147
148
  fi
148
149
  cd "$rvm_ruby_src_path"
149
150
 
150
151
  mkdir -p "$rvm_ruby_log_path"
151
152
  mkdir -p "${rvm_ruby_home}/lib/ruby/gems/1.8/gems"
152
- if [ ! -z "$rvm_ruby_configure" ] ; then rvm_ruby_configure="-c $rvm_ruby_configure"; fi
153
- __rvm_run "install" "./installer -a $rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level --dont-install-useful-gems $rvm_ruby_configure" "Installing $rvm_ruby_string, this may take a while, depending on your cpu(s)..." # --no-tcmalloc
154
- if [ $? -gt 0 ] ; then result=$? ; return $result ; fi
153
+ if [[ ! -z "$rvm_ruby_configure" ]] ; then rvm_ruby_configure="-c $rvm_ruby_configure"; fi
154
+ __rvm_run "install" "./installer -a $rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level $rvm_ree_options --dont-install-useful-gems $rvm_ruby_configure" "Installing $rvm_ruby_string, this may take a while, depending on your cpu(s)..." # --no-tcmalloc
155
+ if [[ $? -gt 0 ]] ; then result=$? ; return $result ; fi
155
156
  chmod +x $rvm_ruby_home/bin/*
156
157
 
157
158
  __rvm_rubygems_setup
@@ -168,7 +169,7 @@ function __rvm_install_ruby {
168
169
  __rvm_pushpop
169
170
  else
170
171
  rvm_url="$(__rvm_db "ree_${rvm_ruby_version}_repo_url")"
171
- if [ -z "$rvm_url" ] ; then
172
+ if [[ -z "$rvm_url" ]] ; then
172
173
  __rvm_log "fail" "rvm does not know the rvm repo url for 'ree_${rvm_ruby_version}'"
173
174
  result=1
174
175
  else
@@ -195,7 +196,7 @@ function __rvm_install_ruby {
195
196
  RBX_PREFIX=$rvm_ruby_home ; export RBX_PREFIX
196
197
  # Also see 'rakelib/configuration.rake'
197
198
 
198
- if [ ! -d "$rvm_ruby_src_path" -o ! -d "$rvm_ruby_src_path/.git" ] ; then
199
+ if [[ ! -d "$rvm_ruby_src_path" ]] || [[ ! -d "$rvm_ruby_src_path/.git" ]] ; then
199
200
  rm -rf $rvm_ruby_src_path
200
201
  __rvm_run "rbx.repo" "git clone --depth 1 $rvm_ruby_repo_url $rvm_ruby_src_path" "Cloning $rvm_ruby_repo_url"
201
202
  cd $rvm_ruby_home
@@ -210,7 +211,7 @@ function __rvm_install_ruby {
210
211
  rvm_ruby_interpreter="rbx"
211
212
  __rvm_select
212
213
 
213
- if [ ! -z "$rvm_jit_flag" ]; then
214
+ if [[ ! -z "$rvm_jit_flag" ]] ; then
214
215
  __rvm_run "configure" "./configure --prefix=$rvm_ruby_home --enable-llvm" "Configuring rbx with LLVM enabled"
215
216
  else
216
217
  __rvm_run "configure" "./configure --prefix=$rvm_ruby_home" "Configuring rbx"
@@ -225,8 +226,8 @@ function __rvm_install_ruby {
225
226
 
226
227
  __rvm_run "rake.install" "$rvm_ruby_home/bin/rbx gem install rake --no-rdoc --no-ri" "Installing Rake"
227
228
  binary=rake
228
- if [ -f $rvm_ruby_gem_home/bin/$binary ] ; then
229
- if [ "$rvm_ruby_gem_home" != "$rvm_ruby_home" ] ; then
229
+ if [[ -f $rvm_ruby_gem_home/bin/$binary ]] ; then
230
+ if [[ "$rvm_ruby_gem_home" != "$rvm_ruby_home" ]] ; then
230
231
  cp $rvm_ruby_gem_home/bin/$binary $rvm_ruby_home/bin/$binary
231
232
  fi
232
233
  chmod +x $rvm_ruby_home/bin/$binary
@@ -239,7 +240,7 @@ function __rvm_install_ruby {
239
240
 
240
241
  binaries="gem" # Trick to work in more shells :)
241
242
  for binary_name in $(echo $binaries); do
242
- if [ $binary_name != "gem" ] ; then prefix="-S" ; fi
243
+ if [[ $binary_name != "gem" ]] ; then prefix="-S" ; fi
243
244
  ruby_wrapper=$(cat <<RubyWrapper
244
245
  #!/bin/bash
245
246
 
@@ -255,7 +256,7 @@ RubyWrapper
255
256
  for file_name in $(echo $files) ; do
256
257
  rm -f $file_name
257
258
  echo "$ruby_wrapper" > $file_name
258
- if [ -f $file_name ] ; then chmod +x $file_name ; fi
259
+ if [[ -f $file_name ]] ; then chmod +x $file_name ; fi
259
260
  done ; unset file_name
260
261
  unset ruby_wrapper binary_name files prefix
261
262
  done
@@ -267,23 +268,23 @@ RubyWrapper
267
268
  mkdir -p $rvm_ruby_log_path
268
269
  __rvm_pushpop $rvm_src_path
269
270
 
270
- if [ ! -z "$rvm_ruby_revision" ] ; then
271
- if [ ! -d $rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version -o ! -d $rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version/.git ] ; then
271
+ if [[ ! -z "$rvm_ruby_revision" ]] ; then
272
+ if [[ ! -d "$rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version" ]] || [[ ! -d "$rvm_path/$rvm_ruby_interpreter-$rvm_ruby_version/.git" ]] ; then
272
273
  git clone --depth 1 $rvm_jruby_repo_url $rvm_ruby_src_path
273
274
  cd $rvm_ruby_src_path && ant # TODO: Test if 'ant' is installed, if not throw error.
274
275
  fi
275
276
  else
276
- if [ -d $rvm_ruby_src_path ] ; then
277
+ if [[ -d $rvm_ruby_src_path ]] ; then
277
278
  cd $rvm_ruby_src_path
278
279
  else
279
- if [ -z "$rvm_force_flag" -a -f $rvm_package_file -a -s $rvm_package_file ] ; then
280
+ if [[ -z "$rvm_force_flag" ]] && [[ -f $rvm_package_file ]] && [[ -s $rvm_package_file ]] ; then
280
281
  __rvm_log "info" "It appears that $rvm_package_file has already been downloaded, skipping. Use --force to force re-download."
281
282
  else
282
283
  __rvm_log "info" "Downloading $rvm_package_file, this may take a while depending on your connection..."
283
284
  __rvm_fetch $rvm_url
284
285
  fi
285
286
  __rvm_run "extract" "tar zxf $rvm_archives_path/$rvm_package_file.tar.gz -C $rvm_src_path" "Extracting $rvm_package_file..."
286
- if [ "$rvm_package_file" != "$rvm_ruby_string" ] ; then
287
+ if [[ "$rvm_package_file" != "$rvm_ruby_string" ]] ; then
287
288
  mv $rvm_src_path/$rvm_package_file $rvm_src_path/$rvm_ruby_string
288
289
  fi
289
290
  cd $rvm_ruby_src_path
@@ -294,7 +295,7 @@ RubyWrapper
294
295
  __rvm_run "nailgun" "cd $rvm_ruby_src_path/tool/nailgun && /usr/bin/make $rvm_make_flags" "Installing $rvm_ruby_package_name..."
295
296
  __rvm_pushpop
296
297
 
297
- if [ -z "$rvm_ruby_home" -o "$rvm_ruby_home" = "/" ] ; then echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000 ; fi
298
+ if [[ -z "$rvm_ruby_home" ]] || [[ "$rvm_ruby_home" = "/" ]] ; then echo "WTH?!?! rvm_ruby_home == / ??? not removing." ; return 1000000 ; fi
298
299
  rm -rf $rvm_ruby_home
299
300
  __rvm_run "install" "/bin/cp -Rf $rvm_ruby_src_path $rvm_ruby_home" "Installing JRuby to $rvm_ruby_home"
300
301
 
@@ -333,31 +334,34 @@ RubyWrapper
333
334
 
334
335
  esac
335
336
 
336
- if [ ! -z "$ruby_options" ] ; then RUBYOPT=$ruby_options ; export RUBYOPT ; fi
337
+ if [[ ! -z "$ruby_options" ]] ; then RUBYOPT=$ruby_options ; export RUBYOPT ; fi
337
338
  }
338
339
 
339
340
  function __rvm_manage_rubies {
340
341
  __rvm_state
341
342
  rubies=() ; successes=() ; errors=() ; statuses=()
343
+ unset rvm_gem_set_name
344
+ rvm_ruby_gem_home=$(echo $rvm_ruby_gem_home | awk -F'%' '{print $1}')
345
+ rvm_ruby_string=$(echo $rvm_ruby_string | awk -F'%' '{print $1}')
342
346
  # TODO: Extract the common functionality out of the if below
343
- if [ ! -z "$rvm_ruby_string" ] ; then
347
+ if [[ ! -z "$rvm_ruby_string" ]] ; then
344
348
  unset rvm_ruby_interpreter rvm_ruby_version
345
349
  __rvm_${rvm_action}_ruby
346
- elif [ ! -z "$rvm_ruby_version" ] ;then
350
+ elif [[ ! -z "$rvm_ruby_version" ]] ;then
347
351
  for rvm_ruby_string in $(echo $rvm_ruby_version | tr ',' ' ') ; do
348
- __rvm_${rvm_action}_ruby
352
+ eval "__rvm_${rvm_action}_ruby"
349
353
  __rvm_unset_ruby_variables
350
354
  done
351
- elif [ ! -z "$rvm_ruby_interpreter" ] ; then
355
+ elif [[ ! -z "$rvm_ruby_interpreter" ]] ; then
352
356
  unset rvm_ruby_string rvm_ruby_version
353
- __rvm_${rvm_action}_ruby
357
+ eval "__rvm_${rvm_action}_ruby"
354
358
  else # all
355
- if [ "$rvm_action" != "install" ] ; then
359
+ if [[ "$rvm_action" != "install" ]] ; then
356
360
  while read bin_line
357
361
  do # Keep this on second line damnit!
358
- if [ -x $bin_line ] ; then
359
- rvm_ruby_string="$(dirname $bin_line | xargs dirname | xargs basename)"
360
- __rvm_${rvm_action}_ruby
362
+ if [[ -x "$bin_line" ]] ; then
363
+ rvm_ruby_string="$(dirname "$bin_line" | xargs dirname | xargs basename)"
364
+ eval "__rvm_${rvm_action}_ruby"
361
365
  __rvm_unset_ruby_variables
362
366
  fi
363
367
  done < <(/bin/ls $rvm_path/*/bin/ruby 2> /dev/null)
@@ -367,23 +371,23 @@ function __rvm_manage_rubies {
367
371
  fi
368
372
  __rvm_state
369
373
 
370
- if [ ! -z "$rvm_summary_flag" ] ; then __rvm_summary ; fi
371
- if [ ! -z "$rvm_yaml_flag" ] ; then __rvm_yaml ; fi
372
- if [ ! -z "$rvm_json_flag" ] ; then __rvm_json ; fi
374
+ if [[ ! -z "$rvm_summary_flag" ]] ; then __rvm_summary ; fi
375
+ if [[ ! -z "$rvm_yaml_flag" ]] ; then __rvm_yaml ; fi
376
+ if [[ ! -z "$rvm_json_flag" ]] ; then __rvm_json ; fi
373
377
  }
374
378
 
375
379
  function __rvm_uninstall_ruby {
376
- if [ -z "$rvm_ruby_selected_flag" ] ; then __rvm_select $* ; fi
380
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
377
381
 
378
- if [ ! -z "$rvm_ruby_package_name" ] ; then
382
+ if [[ ! -z "$rvm_ruby_package_name" ]] ; then
379
383
  for dir in $rvm_path ; do
380
- if [ -d $dir/$rvm_ruby_package_name ] ; then
384
+ if [[ -d $dir/$rvm_ruby_package_name ]] ; then
381
385
  __rvm_log "info" "Removing $dir/$rvm_ruby_package_name..."
382
386
  rm -rf $dir/$rvm_ruby_package_name
383
387
  else
384
388
  __rvm_log "info" "$dir/$rvm_ruby_package_name has already been removed."
385
389
  fi
386
- if [ -e $rvm_bin_path/$rvm_ruby_package_name ] ; then
390
+ if [[ -e $rvm_bin_path/$rvm_ruby_package_name ]] ; then
387
391
  rm -f $rvm_bin_path/$rvm_ruby_package_name
388
392
  fi
389
393
  done ; unset dir
@@ -394,17 +398,17 @@ function __rvm_uninstall_ruby {
394
398
  }
395
399
 
396
400
  function __rvm_remove_ruby {
397
- if [ -z "$rvm_ruby_selected_flag" ] ; then __rvm_select $* ; fi
401
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
398
402
 
399
- if [ ! -z "$rvm_ruby_package_name" ] ; then
403
+ if [[ ! -z "$rvm_ruby_package_name" ]] ; then
400
404
  for dir in $rvm_src_path $rvm_path ; do
401
- if [ -d $dir/$rvm_ruby_package_name ] ; then
405
+ if [[ -d $dir/$rvm_ruby_package_name ]] ; then
402
406
  __rvm_log "info" "Removing $dir/$rvm_ruby_package_name..."
403
407
  rm -rf $dir/$rvm_ruby_package_name
404
408
  else
405
409
  __rvm_log "info" "it seems that $dir/$rvm_ruby_package_name is already non existent."
406
410
  fi
407
- if [ -e $rvm_bin_path/$rvm_ruby_package_name ] ; then
411
+ if [[ -e $rvm_bin_path/$rvm_ruby_package_name ]] ; then
408
412
  rm -f $rvm_bin_path/$rvm_ruby_package_name
409
413
  fi
410
414
  done ; unset dir
@@ -416,15 +420,15 @@ function __rvm_remove_ruby {
416
420
  function __rvm_post_install {
417
421
  binaries="${binaries:-"gem irb erb ri rdoc testrb rake"}"
418
422
  for binary in $(echo $binaries) ; do
419
- if [ -e $rvm_ruby_home/bin/$binary -o -e $rvm_ruby_src_path/bin/$binary ] ; then
420
- if [ "$rvm_ruby_src_path" != "$rvm_ruby_home" -a -f $rvm_ruby_src_path/bin/$binary ] ; then
421
- cp -f $rvm_ruby_src_path/bin/$binary $rvm_ruby_home/bin/$binary
422
- elif [ -f "$rvm_ruby_gem_home/bin/$binary" ] ; then
423
- cp -f $rvm_ruby_gem_home/bin/$binary $rvm_ruby_home/bin/$binary
423
+ if [[ -e "$rvm_ruby_home/bin/$binary" ]] || [[ -e "$rvm_ruby_src_path/bin/$binary" ]] ; then
424
+ if [[ "$rvm_ruby_src_path" != "$rvm_ruby_home" ]] && [[ -f "$rvm_ruby_src_path/bin/$binary" ]] ; then
425
+ cp -f "$rvm_ruby_src_path/bin/$binary" "$rvm_ruby_home/bin/$binary"
426
+ elif [[ -f "$rvm_ruby_gem_home/bin/$binary" ]] ; then
427
+ cp -f "$rvm_ruby_gem_home/bin/$binary" "$rvm_ruby_home/bin/$binary"
424
428
  fi
425
- __rvm_inject_gem_env $rvm_ruby_home/bin/$binary
426
- __rvm_inject_ruby_shebang $rvm_ruby_home/bin/$binary
427
- chmod +x $rvm_ruby_home/bin/$binary
429
+ __rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
430
+ __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/$binary"
431
+ chmod +x "$rvm_ruby_home/bin/$binary"
428
432
  fi
429
433
  done ; unset binary binaries
430
434
 
@@ -437,8 +441,8 @@ function __rvm_post_install {
437
441
  __rvm_log "info" "Installation of gems for $rvm_ruby_package_name is complete."
438
442
 
439
443
  binary=rake
440
- if [ -x $rvm_ruby_gem_home/bin/$binary ] ; then
441
- if [ "$rvm_ruby_gem_home" != "$rvm_ruby_home" ] ; then
444
+ if [[ -x $rvm_ruby_gem_home/bin/$binary ]] ; then
445
+ if [[ "$rvm_ruby_gem_home" != "$rvm_ruby_home" ]] ; then
442
446
  cp $rvm_ruby_gem_home/bin/$binary $rvm_ruby_home/bin/$binary
443
447
  fi
444
448
  __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/$binary"
@@ -447,7 +451,7 @@ function __rvm_post_install {
447
451
  }
448
452
 
449
453
  function __rvm_rubygems_setup {
450
- if [ ! -z "$(echo $rvm_ruby_version | awk '/^1\.9/')" ] ; then
454
+ if [[ ! -z "$(echo $rvm_ruby_version | awk '/^1\.9/')" ]] ; then
451
455
  # 1.9 has it's own built-in gem command
452
456
  __rvm_inject_ruby_shebang "$rvm_ruby_src_path/bin/gem"
453
457
  __rvm_inject_gem_env "$rvm_ruby_home/bin/gem"
@@ -456,24 +460,24 @@ function __rvm_rubygems_setup {
456
460
  __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/gem"
457
461
  __rvm_inject_gem_env "$rvm_ruby_home/bin/gem"
458
462
 
459
- elif [ ! -z "$(echo $rvm_ruby_interpreter | awk '/^rbx|jruby/')" ] ; then
463
+ elif [[ ! -z "$(echo $rvm_ruby_interpreter | awk '/^rbx|jruby/')" ]] ; then
460
464
  __rvm_log "debug" "Skipping rubygems update for $rvm_ruby_version"
461
465
 
462
466
  else
463
467
  __rvm_log "info" "Installing rubygems dedicated to $rvm_ruby_package_name..."
464
468
  rvm_gem_package_name="rubygems-1.3.5"
465
469
  rvm_gem_url="http://rubyforge.org/frs/download.php/60718/$rvm_gem_package_name.tgz"
466
- if [ -d $rvm_src_path/$rvm_gem_package_name ] ; then
467
- cd $rvm_src_path/$rvm_gem_package_name
470
+ if [[ -d "$rvm_src_path/$rvm_gem_package_name" ]] ; then
471
+ cd "$rvm_src_path/$rvm_gem_package_name"
468
472
  else
469
473
  __rvm_log "info" "Retrieving $rvm_gem_package_name"
470
- __rvm_fetch $rvm_gem_url
471
- mkdir -p $rvm_src_path/$rvm_gem_package_name
474
+ __rvm_fetch "$rvm_gem_url"
475
+ mkdir -p "$rvm_src_path/$rvm_gem_package_name"
472
476
  __rvm_run "rubygems.extract" "tar zxf $rvm_archives_path/$rvm_gem_package_name.tgz -C $rvm_src_path" "Extracting $rvm_gem_package_name"
473
477
  fi
474
478
  __rvm_run "rubygems.install" "GEM_PATH=$rvm_gem_path GEM_HOME=$rvm_ruby_gem_home $rvm_ruby_home/bin/ruby $rvm_src_path/$rvm_gem_package_name/setup.rb" "Installing rubygems for $rvm_ruby_home/bin/ruby"
475
479
  result=$?
476
- if [ $result -eq 0 ] ; then
480
+ if [[ $result -eq 0 ]] ; then
477
481
  __rvm_log "info" "Installation of rubygems $rvm_ruby_package_name completed successfully."
478
482
  else
479
483
  __rvm_log "warning" "Installation of rubygems $rvm_ruby_package_name did not complete successfully."
@@ -485,30 +489,30 @@ function __rvm_rubygems_setup {
485
489
 
486
490
  function __rvm_inject_ruby_shebang {
487
491
  __rvm_actual_file $1
488
- if [ -f $actual_file ] ; then
492
+ if [[ -f "$actual_file" ]] ; then
489
493
  sed -i.orig -e "s=env [j]*ruby=env $rvm_ruby_home/bin/ruby=" $actual_file
490
- rm -f $actual_file.orig ; chmod +x $actual_file
494
+ rm -f $actual_file.orig ; chmod +x "$actual_file"
491
495
  fi ; unset actual_file
492
496
  }
493
497
 
494
498
  function __rvm_inject_gem_env {
495
499
  __rvm_actual_file $1
496
- if [ -f $actual_file ] ; then
497
- if [ ! -z "$(head -n 1 $actual_file | awk '/[j]*ruby/')" ] ; then
500
+ if [[ -f "$actual_file" ]] ; then
501
+ if [[ ! -z "$(head -n 1 $actual_file | awk '/[j]*ruby/')" ]] ; then
498
502
  string="ENV['GEM_HOME']=ENV['GEM_HOME'] || '$rvm_ruby_gem_home'\nENV['GEM_PATH']=ENV['GEM_PATH'] || '$rvm_ruby_gem_home'\nENV['PATH']='$rvm_ruby_home/bin:$rvm_ruby_gem_home/bin:' + ENV['PATH']"
499
- elif [ ! -z "$(head -n 1 $actual_file | awk '/bash/')" ] ; then
503
+ elif [[ ! -z "$(head -n 1 $actual_file | awk '/bash/')" ]] ; then
500
504
  string="GEM_HOME=\${GEM_HOME:-'$rvm_ruby_gem_home'}\nGEM_PATH=\${GEM_PATH:-'$rvm_ruby_gem_home'}\nPATH=$rvm_ruby_home/bin:$rvm_ruby_gem_home/bin:\$PATH"
501
505
  fi
502
- if [ ! -z "$string" ] ; then
503
- awk "NR==2 {print \"$string\"} {print}" $actual_file > $actual_file.new
504
- mv $actual_file.new $actual_file ; chmod +x $actual_file
506
+ if [[ ! -z "$string" ]] ; then
507
+ awk "NR==2 {print \"$string\"} {print}" "$actual_file" > "$actual_file.new"
508
+ mv $actual_file.new $actual_file ; chmod +x "$actual_file"
505
509
  unset string
506
510
  fi
507
511
  fi ; unset actual_file
508
512
  }
509
513
 
510
514
  function __rvm_actual_file {
511
- if [ -L $1 ] ; then # If the file is a symlink,
515
+ if [[ -L $1 ]] ; then # If the file is a symlink,
512
516
  actual_file="$(readlink $1)" # read the link target so we can preserve it.
513
517
  else
514
518
  actual_file="$1"