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/utility CHANGED
@@ -37,20 +37,20 @@ function __rvm_debug {
37
37
  __rvm_log "debug" "\nPATH:\n$(echo $PATH | awk -F":" '{print $1":"$2":"$3":"$4":"$5}')"
38
38
 
39
39
  for file_name in ~/.bash_profile ~/.bashrc ~/.zshrc ; do
40
- if [ -s $file_name ] ; then
40
+ if [[ -s "$file_name" ]] ; then
41
41
  __rvm_log "debug" "\n$file_name:\n$(grep 'rvm' $file_name)"
42
42
  fi
43
43
  done
44
44
 
45
45
  for file_name in $rvm_path/default $rvm_path/system $rvm_path/config/db ~/.rvmrc ~/.gemrc; do
46
- if [ -f $file_name -a -s $file_name ] ; then
46
+ if [[ -f "$file_name" ]] && [[ -s "$file_name" ]] ; then
47
47
  __rvm_log "debug" "$file_name (filtered):\n$(cat $file_name | awk '!/assword|_key/')\n"
48
48
  fi
49
49
  done
50
50
 
51
51
  __rvm_log "debug" "gem sources:\n$(gem sources | awk '/gems/')"
52
52
 
53
- if [ -f $rvm_path/bin/rvm ] ; then
53
+ if [[ -f "$rvm_path/bin/rvm" ]] ; then
54
54
  __rvm_log "error" "rvm script in bin! \n$(ls -laht $rvm_path/bin/rvm)"
55
55
  fi
56
56
  }
@@ -58,7 +58,7 @@ function __rvm_debug {
58
58
  # Logging functions based on level
59
59
  # TODO: Allow specification of a base file name to output to.
60
60
  function __rvm_log {
61
- if [ ! -z "$2" ] ; then level=$1 ; shift ; else level="info" ; fi
61
+ if [[ ! -z "$2" ]] ; then level=$1 ; shift ; else level="info" ; fi
62
62
  message=$1
63
63
  case "$level" in
64
64
  debug) shift ;
@@ -72,7 +72,7 @@ function __rvm_log {
72
72
  esac
73
73
  }
74
74
 
75
- if [ ! -z "$ZSH_VERSION" ] ; then __shell_array_start=1 ; else __shell_array_start=0 ; fi
75
+ if [[ ! -z "$ZSH_VERSION" ]] ; then __shell_array_start=1 ; else __shell_array_start=0 ; fi
76
76
  __rvm_push() {
77
77
  array=$1 ; shift ; item=$2
78
78
  # TODO: allow loop over more arguments.
@@ -98,16 +98,16 @@ function __rvm_run {
98
98
  rvm_ruby_log_path="${rvm_ruby_log_path:-$rvm_path/log}"
99
99
  mkdir -p $(dirname "$rvm_ruby_log_path/$log_file_name.log")
100
100
 
101
- if [ ! -z "$message" ] ; then __rvm_log "info" "$message" ; fi
101
+ if [[ ! -z "$message" ]] ; then __rvm_log "info" "$message" ; fi
102
102
  __rvm_log "debug" "Executing: $command"
103
103
  touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :(
104
104
  echo "[$(date +'%Y-%m-%d %H:%M:%S')] $command" | tee "$rvm_ruby_log_path/$log_file_name.log" > "$rvm_ruby_log_path/$log_file_name.error.log"
105
- if [ -z "$rvm_niceness" -o "0" = "$rvm_niceness" ] ; then
105
+ if [[ -z "$rvm_niceness" ]] || [[ "0" = "$rvm_niceness" ]] ; then
106
106
  eval "$command" >> "$rvm_ruby_log_path/$log_file_name.log" 2>> "$rvm_ruby_log_path/$log_file_name.error.log"
107
107
  else
108
108
  eval "nice -n $rvm_niceness \$($command)" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log
109
109
  fi
110
- if [ $? -gt 0 ] ; then __rvm_log "error" "Error running '$command', please check $rvm_ruby_log_path/$log_file_name.error.log" ; __rvm_pushpop ; return 1 ; fi
110
+ if [[ $? -gt 0 ]] ; then __rvm_log "error" "Error running '$command', please check $rvm_ruby_log_path/$log_file_name.error.log" ; __rvm_pushpop ; return 1 ; fi
111
111
  unset log_file command
112
112
  }
113
113
 
@@ -122,13 +122,13 @@ function __rvm_unset_ruby_variables {
122
122
 
123
123
  # TODO: root user loadng of /etc/rvmrc
124
124
  function __rvm_load_rvmrc {
125
- if [ -s ~/.rvmrc ] ; then source ~/.rvmrc ; fi
125
+ if [[ -s ~/.rvmrc ]] ; then source ~/.rvmrc ; fi
126
126
  }
127
127
 
128
128
  function __rvm_bin_scripts {
129
129
  for rvm_ruby_binary in $(/bin/ls $rvm_path/*/bin/ruby 2> /dev/null) ; do
130
- if [ -x $rvm_ruby_binary ] ; then
131
- rvm_ruby_string=$(dirname $rvm_ruby_binary | xargs dirname | xargs basename)
130
+ if [[ -x "$rvm_ruby_binary" ]] ; then
131
+ rvm_ruby_string=$(dirname "$rvm_ruby_binary" | xargs dirname | xargs basename)
132
132
  __rvm_select
133
133
  __rvm_bin_script
134
134
  fi
@@ -136,7 +136,7 @@ function __rvm_bin_scripts {
136
136
  }
137
137
 
138
138
  function __rvm_bin_script {
139
- if [ -z "$rvm_ruby_selected_flag" ] ; then __rvm_select $* ; fi
139
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
140
140
  ruby_wrapper=$(cat <<RubyWrapper
141
141
  #!/bin/bash
142
142
 
@@ -156,12 +156,13 @@ RubyWrapper
156
156
 
157
157
  function __rvm_fetch {
158
158
  __rvm_pushpop $rvm_archives_path
159
- archive=$(basename "$1")
159
+ if [[ -z "$1" ]] ; then log "fail" "BUG: __rvm_fetch called without an argument :/" ; return 1 ; fi
160
+ archive=$(basename "$1") ; downlaod=1
160
161
  __rvm_log "debug" "Fetching $archive"
161
162
  # Check first if we have the correct archive
162
- if [ -e "$archive" ] && [ -e "$archive.md5" ] ; then
163
+ if [[ -e "$archive" ]] && [[ -e "$archive.md5" ]] ; then
163
164
  __rvm_log "debug" "Found archive and its md5, testing correctness"
164
- if [ $(md5sum --status -c "$archive.md5") -gt 0 ] ; then
165
+ if [[ $(md5sum --status -c "$archive.md5") -gt 0 ]] ; then
165
166
  __rvm_log "debug" "Archive is bad, downloading"
166
167
  download=1
167
168
  else
@@ -173,19 +174,18 @@ function __rvm_fetch {
173
174
  __rvm_log "debug" "No archive or no MD5, downloading"
174
175
  download=1
175
176
  fi
176
-
177
- if [ $download -gt 0 ] ; then
177
+ if [[ $download -gt 0 ]] ; then
178
178
  eval $rvm_fetch "$1"
179
179
  result=$?
180
- if [ $result -gt 0 ] ; then
181
- unset retry
182
- if [ $result -eq 78 ] ; then
180
+ if [[ $result -gt 0 ]] ; then
181
+ retry=0
182
+ if [[ $result -eq 78 ]] ; then
183
183
  __rvm_log "error" "The requested url does not exist: '$1'"
184
- elif [ $result -eq 18 ] ; then
184
+ elif [[ $result -eq 18 ]] ; then
185
185
  __rvm_log "error" "Partial file. Only a part of the file was transferred. Removing partial and re-trying."
186
186
  rm -f "$archive"
187
187
  retry=1
188
- elif [ $result -eq 33 ] ; then
188
+ elif [[ $result -eq 33 ]] ; then
189
189
  __rvm_log "debug" "Server does not support 'range' command, removing '$archive'"
190
190
  rm -f "$archive"
191
191
  retry=1
@@ -193,10 +193,10 @@ function __rvm_fetch {
193
193
  __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
194
194
  fi
195
195
 
196
- if [ $retry -eq 1 ] ; then
196
+ if [[ $retry -eq 1 ]] ; then
197
197
  eval $rvm_fetch "$1"
198
198
  result=$?
199
- if [ $result -gt 0 ] ; then
199
+ if [[ $result -gt 0 ]] ; then
200
200
  __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
201
201
  fi
202
202
  fi
@@ -211,10 +211,10 @@ function __rvm_fetch {
211
211
  }
212
212
 
213
213
  function __rvm_load_defaults {
214
- if [ ! -s $rvm_path/system ] ; then
214
+ if [[ ! -s "$rvm_path/system" ]] ; then
215
215
  for variable in RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME ; do
216
216
  eval value=\$${variable}
217
- if [ -z "$value" ] ; then
217
+ if [[ -z "$value" ]] ; then
218
218
  echo "unset ${variable}" >> $rvm_path/system
219
219
  else
220
220
  eval "export $variable"
@@ -225,21 +225,21 @@ function __rvm_load_defaults {
225
225
  fi
226
226
 
227
227
  rvm_system_ruby=$(__rvm_db "system_ruby")
228
- if [ ! -z "$rvm_system_ruby" ] ; then
228
+ if [[ ! -z "$rvm_system_ruby" ]] ; then
229
229
  rvm_system_ruby=$(which ruby)
230
- if [ $? -ne 0 ] ; then
230
+ if [[ $? -ne 0 ]] ; then
231
231
  __rvm_log "info" "System ruby not found, no db will be stored."
232
232
  else
233
233
  __rvm_db "system_ruby" "$rvm_system_ruby"
234
234
 
235
235
  # Now store system system & user gem paths
236
236
  rvm_system_user_gem_path=$(__rvm_db "system_user_gem_path")
237
- if [ -z "$rvm_system_user_gem_path" ] ; then
237
+ if [[ -z "$rvm_system_user_gem_path" ]] ; then
238
238
  rvm_system_user_gem_path=$( rvm system ; gem env gemdir user; )
239
239
  __rvm_db "system_user_gem_path" "$rvm_system_user_gem_path"
240
240
  fi
241
241
  rvm_system_gem_path=$(__rvm_db "system_gem_path")
242
- if [ -z "$rvm_system_gem_path" ] ; then
242
+ if [[ -z "$rvm_system_gem_path" ]] ; then
243
243
  rvm_system_gem_path=$( rvm system ; gem env gemdir; )
244
244
  __rvm_db "system_gem_path" "$rvm_system_gem_path"
245
245
  fi
@@ -254,7 +254,7 @@ function __rvm_reset {
254
254
  for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do unset $variable ; done
255
255
 
256
256
  for file in system default ; do
257
- if [ -f $rvm_path/$file ] ; then rm -f $rvm_path/$file ; fi
257
+ if [[ -f "$rvm_path/$file" ]] ; then rm -f $rvm_path/$file ; fi
258
258
  done
259
259
  rvm_ruby_interpreter="system"
260
260
  __rvm_select
@@ -270,11 +270,11 @@ function __rvm_implode {
270
270
  while : ; do
271
271
  __rvm_log "warn" "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')"
272
272
  read response
273
- if [ "yes" = "$response" ] ; then
274
- if [ "/" = "$rvm_path" ] ; then
273
+ if [[ "yes" = "$response" ]] ; then
274
+ if [[ "/" = "$rvm_path" ]] ; then
275
275
  __rvm_log "error" "remove '/' ?!... NO!"
276
276
  else
277
- if [ -d $rvm_path ] ; then
277
+ if [[ -d "$rvm_path" ]] ; then
278
278
  __rvm_log "info" "Hai! Removing $rvm_path"
279
279
  rm -rf $rvm_path/
280
280
  __rvm_log "info" "$rvm_path has been removed."
@@ -283,7 +283,7 @@ function __rvm_implode {
283
283
  fi
284
284
  fi
285
285
  break
286
- elif [ "no" = "$response" ] ; then
286
+ elif [[ "no" = "$response" ]] ; then
287
287
  __rvm_log "info" "Cancelling implosion, no harm done :)"
288
288
  break
289
289
  fi
@@ -291,14 +291,14 @@ function __rvm_implode {
291
291
  }
292
292
 
293
293
  function __rvm_gemdir {
294
- if [ -z "$rvm_ruby_selected_flag" ] ; then __rvm_select $* ; fi
294
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
295
295
  mkdir -p $rvm_ruby_gem_home
296
296
  echo $rvm_ruby_gem_home
297
297
  }
298
298
 
299
299
  function __rvm_source_dir {
300
- if [ -z "$rvm_ruby_selected_flag" ] ; then __rvm_select $* ; fi
301
- if [ -z "$rvm_ruby_src_path" ] ; then
300
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
301
+ if [[ -z "$rvm_ruby_src_path" ]] ; then
302
302
  __rvm_log "fail" "No source directory exists for the default implementation."
303
303
  else
304
304
  echo "$rvm_ruby_src_path"
@@ -308,14 +308,14 @@ function __rvm_source_dir {
308
308
  # clones from source implementation/version to default
309
309
  # TODO: Merge this into 'rvm sync'
310
310
  function __rvm_gemdup {
311
- if [ -z "$rvm_ruby_selected_flag" ] ; then __rvm_select $* ; fi
311
+ if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi
312
312
  __rvm_log "debug" "$rvm_ruby_interpreter"
313
- if [ "default" = "$rvm_ruby_interpreter" ] ; then
313
+ if [[ "default" = "$rvm_ruby_interpreter" ]] ; then
314
314
  # TODO: ~/.rvm/default first, then system user
315
315
  rvm_source_gem_path="$rvm_system_user_gem_path"
316
- elif [ "user" = "$rvm_ruby_interpreter" ] ; then
316
+ elif [[ "user" = "$rvm_ruby_interpreter" ]] ; then
317
317
  rvm_source_gem_path="$rvm_system_user_gem_path"
318
- elif [ "system" = "$rvm_ruby_interpreter" ] ; then
318
+ elif [[ "system" = "$rvm_ruby_interpreter" ]] ; then
319
319
  rvm_source_gem_path="$rvm_system_gem_path"
320
320
  else
321
321
  # TODO: use selector for this?
@@ -325,11 +325,11 @@ function __rvm_gemdup {
325
325
  }
326
326
 
327
327
  function __rvm_gem_sync {
328
- if [ ! -z "$rvm_source_gem_path" ] ; then
328
+ if [[ ! -z "$rvm_source_gem_path" ]] ; then
329
329
  for rvm_gem_name_version in $rvm_source_gem_path/gems/* ; do
330
330
  rvm_gem_name="${rvm_gem_name_version%-*}"
331
331
  rvm_gem_version="${rvm_gem_name_version##*-}"
332
- if [ -d $GEM_HOME/gems/$rvm_gem_name_version ] ; then
332
+ if [[ -d $GEM_HOME/gems/$rvm_gem_name_version ]] ; then
333
333
  echo "$rvm_gem_name_version already installed."
334
334
  else
335
335
  __rvm_gi "$rvm_source_gem_path/cache/$rvm_gem_name-$rvm_gem_version.gem"
@@ -347,20 +347,20 @@ function __rvm_db {
347
347
  touch $rvm_hash_file
348
348
  key="$1" ; shift
349
349
 
350
- if [ -z "$key" ] ; then
350
+ if [[ -z "$key" ]] ; then
351
351
  __rvm_log "fail" "__rvm_db must be called with at least one argument: __rvm_db key [value]"
352
352
  else
353
353
  value="$*"
354
- if [ "unset" = "$value" -o "delete" = "$value" ] ; then
355
- sed -i.tmp "s#^$key=.*$\##" $rvm_hash_file
354
+ if [[ "unset" = "$value" ]] || [[ "delete" = "$value" ]] ; then
355
+ sed -i.tmp "s#^$key=.*\$##" $rvm_hash_file
356
356
  else
357
- if [ -z "$value" ] ; then # get
358
- grep "^$key=" $rvm_hash_file | head -n 1 | awk -F'=' '{print $2}'
357
+ if [[ -z "$value" ]] ; then # get
358
+ awk -F= '/^'"$key"'=/{print $2}' $rvm_hash_file
359
359
  else # set
360
- if [ -z "$(grep "^$key=" $rvm_hash_file)" ] ; then # append
360
+ if [[ -z "$(awk -F= "/^'"$key"'=/{print $2}" $rvm_hash_file)" ]] ; then # append
361
361
  echo "$key=$value" >> $rvm_hash_file
362
362
  else # overwrite
363
- sed -i.tmp "s#^$key=.*$\#$key=$value#" $rvm_hash_file
363
+ sed -i.tmp "s#^$key=.*\$#$key=$value#" $rvm_hash_file
364
364
  fi
365
365
  fi
366
366
  fi
@@ -368,13 +368,13 @@ function __rvm_db {
368
368
  }
369
369
 
370
370
  function __rvm_list {
371
- if [ "$rvm_all_flag" ] ; then
371
+ if [[ ! -z "$rvm_all_flag" ]] ; then
372
372
  svn list http://svn.ruby-lang.org/repos/ruby/tags/ | grep 'v1_[8|9]' | sed 's#^v1_##' | sed 's#/$##' | awk -F'_' '{print "1."$1"."$2 " -l "$3}' | sed 's#p$##'
373
373
  echo -e "jruby 1.2.0\njruby 1.3.0\njruby (1.3.1, the default)\njruby 1.4.1\njruby --head"
374
374
  echo -e "rbx head (rubinius head, the default)\nrbx head --jit"
375
375
  echo -e "ree 1.8.6 --head\nree (1.8.7, the default)"
376
376
  else
377
- current_ruby=$(which ruby | xargs dirname | xargs dirname | xargs basename 2> /dev/null)
377
+ current_ruby="$(which ruby | xargs dirname | xargs dirname | xargs basename 2> /dev/null)"
378
378
  echo -e "\nruby:\n"
379
379
  for version in $(/bin/ls -l $rvm_path/ 2> /dev/null | awk '/ ruby-[1-2].*/ { print $NF }') ; do
380
380
  string=$($rvm_path/$version/bin/ruby -v)
@@ -408,9 +408,9 @@ function __rvm_list {
408
408
  fi
409
409
  done ; unset version
410
410
 
411
- if [ -f $rvm_path/default -a -s $rvm_path/default ] ; then
411
+ if [[ -f "$rvm_path/default" ]] && [[ -s $rvm_path/default ]] ; then
412
412
  version=$(grep '^MY_RUBY_HOME' ~/.rvm/default | awk -F"'" '{print $2}' | xargs basename)
413
- if [ ! -z "$version" ] ; then
413
+ if [[ ! -z "$version" ]] ; then
414
414
  echo -e "\ndefault:\n"
415
415
  string=$($rvm_path/$version/bin/ruby -v)
416
416
  if [[ "$version" = "$current_ruby" ]] ; then
@@ -424,7 +424,7 @@ function __rvm_list {
424
424
 
425
425
  echo -e "\nsystem:\n"
426
426
  system_version=$(rvm system ; ruby -v 2> /dev/null)
427
- if [ ! -z "$system_version" ] ; then
427
+ if [[ ! -z "$system_version" ]] ; then
428
428
  if [[ "$($(which ruby) -v)" = "$system_version" ]] ; then
429
429
  echo -e "=> $system_version\n"
430
430
  else
@@ -436,20 +436,20 @@ function __rvm_list {
436
436
 
437
437
  function __rvm_initialize {
438
438
  rvm_fetch=$(which curl)
439
- if [ $? -ne 0 ] ; then
439
+ if [[ $? -ne 0 ]] ; then
440
440
  __rvm_log "fail" "rvm requires curl, which does not seem to exist in your path :("
441
441
  else
442
442
  rvm_fetch="$rvm_fetch -O -L --create-dirs -C - " # -s for silent
443
443
  fi
444
444
 
445
445
  # TODO: Sanitize user input, ensure that there is a / a the end...
446
- if [ "root" = "$(whoami)" ] ; then
446
+ if [[ "root" = "$(whoami)" ]] ; then
447
447
  __rvm_log "fail" "root user support is not yet implemented."
448
448
  rvm_prefix_path="${rvm_prefix_path:-/usr/local/}"
449
449
  else
450
450
  rvm_prefix_path="${rvm_prefix_path:-"$HOME/."}"
451
451
  fi
452
- if [ "${rvm_prefix_path#${rvm_prefix_path%?}}" = '.' -o "${rvm_prefix_path#${rvm_prefix_path%?}}" = '/' ] ; then
452
+ if [[ "${rvm_prefix_path#${rvm_prefix_path%?}}" = '.' ]] || [[ "${rvm_prefix_path#${rvm_prefix_path%?}}" = '/' ]] ; then
453
453
  rvm_path="${rvm_prefix_path}rvm"
454
454
  else
455
455
  rvm_path="${rvm_prefix_path}/rvm"
@@ -471,7 +471,7 @@ function __rvm_initialize {
471
471
 
472
472
  __rvm_clean_path
473
473
  rvm_result=$(echo $PATH | grep 'rvm\/bin:')
474
- if [ -z $rvm_result ] ; then
474
+ if [[ -z "$rvm_result" ]] ; then
475
475
  PATH=$rvm_bin_path:$PATH ; export PATH
476
476
  fi
477
477
 
@@ -479,21 +479,20 @@ function __rvm_initialize {
479
479
  }
480
480
 
481
481
  function __rvm_update {
482
- if [ "head" = "$rvm_ruby_revision" -o ! -z "$rvm_self_flag" -o "update" = "$rvm_action" -o ! -z "$rvm_update_flag" ] ; then
482
+ if [[ "head" = "$rvm_ruby_revision" ]] || [[ ! -z "$rvm_self_flag" ]] || [[ "update" = "$rvm_action" ]] || [[ ! -z "$rvm_update_flag" ]] ; then
483
483
  __rvm_version
484
484
  __rvm_update_rvm
485
485
  __rvm_version
486
486
  fi
487
487
  __rvm_reload
488
- # if [ "$rvm_gem_flag" ] ; then __rvm_gem_scripts ; fi
489
- if [ "$rvm_bin_flag" ] ; then __rvm_bin_scripts ; fi
490
- if [ "$rvm_rubygems_flag" ] ; then __rvm_rubygems_setup ; fi
488
+ if [[ ! -z "$rvm_bin_flag" ]] ; then __rvm_bin_scripts ; fi
489
+ if [[ ! -z "$rvm_rubygems_flag" ]] ; then __rvm_rubygems_setup ; fi
491
490
  }
492
491
 
493
492
  function __rvm_update_rvm {
494
493
  mkdir -p $rvm_src_path
495
- if [ "head" = "$rvm_ruby_revision" ] ; then
496
- if [ -d $rvm_src_path/rvm/.git ] ; then
494
+ if [[ "head" = "$rvm_ruby_revision" ]] ; then
495
+ if [[ -d "$rvm_src_path/rvm/.git" ]] ; then
497
496
  cd $rvm_src_path/rvm/ && git pull origin master && ./scripts/install
498
497
  else
499
498
  cd $rvm_src_path && git clone git://github.com/wayneeseguin/rvm.git && cd rvm/ && ./install
@@ -505,27 +504,25 @@ function __rvm_update_rvm {
505
504
  fi
506
505
  }
507
506
 
508
- function __rvm_reboot {
507
+ __rvm_reboot() {
509
508
  __rvm_log "warn" "Do you wish to reset rvm? ('yes', or 'no')"
510
509
  read response
511
- if [ "yes" = "$response" ] ; then
510
+ if [[ "yes" = "$response" ]] ; then
512
511
  cd
513
512
  __rvm_reset
514
513
  mv ~/.rvm/archives ~/.archives
515
- if [ "/" = "$rvm_path" ] ; then
514
+ if [[ "/" = "$rvm_path" ]] ; then
516
515
  __rvm_log "error" "remove '/' ?!... NO!"
517
516
  else
518
- if [ -d $rvm_path ] ; then
519
- rm -rf $rvm_path/
520
- fi
517
+ if [[ -d "$rvm_path" ]] ; then rm -rf "$rvm_path/" ; fi
521
518
  fi
522
519
  gem install rvm --no-rdoc --no-ri -q
523
520
  which rvm-install 2> /dev/null
524
- if [ $? -gt 0 ] ; then
525
- if [ -e ~/.gem/ruby/1.8/bin/rvm-install ] ; then
521
+ if [[ $? -gt 0 ]] ; then
522
+ if [[ -x "~/.gem/ruby/1.8/bin/rvm-install" ]] ; then
526
523
  ~/.gem/ruby/1.8/bin/rvm-install
527
524
  else
528
- __rvm_log "error" "Could not find rvm-install in your path :("
525
+ __rvm_log "error" "Could not find an executable rvm-install in your path :("
529
526
  fi
530
527
  else
531
528
  rvm-install
@@ -536,20 +533,16 @@ function __rvm_reboot {
536
533
  fi ; unset response
537
534
  }
538
535
 
539
- __rvm_reload() {
540
- source $rvm_path/scripts/rvm
541
- }
542
-
543
536
  __rvm_ruby_do() {
544
537
  __rvm_select
545
538
  __rvm_use
546
539
  binary="$(echo $rvm_action | sed 's#do$##')"
547
- if [ -x $rvm_ruby_home/bin/$binary ] ; then
540
+ if [[ -x "$rvm_ruby_home/bin/$binary" ]] ; then
548
541
  load_path="$rvm_ruby_home/bin:$rvm_ruby_load_path"
549
- if [ "ruby" = "$binary" ] ; then
550
- if [ -z "$(echo $rvm_ruby_args | awk '/\.rb$/')" ] ; then
542
+ if [[ "ruby" = "$binary" ]] ; then
543
+ if [[ -z "$(echo $rvm_ruby_args | awk '/\.rb$/')" ]] ; then
551
544
  #if [[ $rvm_ruby_args =~ '\.rb$' ]] ; then
552
- if [ -z "$prefix" ] ; then prefix="-S" ; fi
545
+ if [[ -z "$prefix" ]] ; then prefix="-S" ; fi
553
546
  if [[ ! -z "$rvm_ruby_args" ]] && [[ ! "$rvm_ruby_args" =~ "$prefix" ]] ; then
554
547
  rvm_ruby_args="$prefix $rvm_ruby_args"
555
548
  fi
@@ -559,7 +552,7 @@ __rvm_ruby_do() {
559
552
  rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_args"
560
553
  fi
561
554
 
562
- if [ ! -z "$rvm_json_flag" -o ! -z "$rvm_yaml_flag" -o ! -z "$rvm_summary_flag" ] ; then
555
+ if [[ ! -z "$rvm_json_flag" ]] || [[ ! -z "$rvm_yaml_flag" ]] || [[ ! -z "$rvm_summary_flag" ]] ; then
563
556
  mkdir -p ./log/$rvm_ruby_string/
564
557
  touch ./log/$rvm_ruby_string/$rvm_action.log ./log/$rvm_ruby_string/$rvm_action.error.log
565
558
  eval "$rvm_command" >> ./log/$rvm_ruby_string/$rvm_action.log 2>> ./log/$rvm_ruby_string/$rvm_action.error.log
@@ -568,7 +561,7 @@ __rvm_ruby_do() {
568
561
  eval "$rvm_command"
569
562
  fi
570
563
  result=$?
571
- if [ $result -eq 0 ]; then
564
+ if [[ $result -eq 0 ]]; then
572
565
  eval "successes=(${successes[*]} $rvm_ruby_string)"
573
566
  else
574
567
  eval "errors=(${errors[*]} $rvm_ruby_string)"
@@ -581,34 +574,34 @@ __rvm_ruby_do() {
581
574
  __rvm_unset_ruby_variables
582
575
  }
583
576
 
584
- function __rvm_do {
577
+ __rvm_do() {
585
578
  __rvm_state
586
579
 
587
580
  rubies=() ; successes=() ; errors=() ; statuses=()
588
581
  # TODO: Extract the common functionality out of the if below
589
- if [ ! -z "$rvm_ruby_string" ] ; then
582
+ if [[ ! -z "$rvm_ruby_string" ]] ; then
590
583
  unset rvm_ruby_interpreter rvm_ruby_version
591
584
  __rvm_ruby_do
592
- elif [ ! -z "$rvm_ruby_version" ] ;then
585
+ elif [[ ! -z "$rvm_ruby_version" ]] ;then
593
586
  for rvm_ruby_string in $(echo $rvm_ruby_version | tr ',' ' ') ; do
594
587
  __rvm_ruby_do
595
588
  done
596
- elif [ ! -z "$rvm_ruby_interpreter" ] ; then
589
+ elif [[ ! -z "$rvm_ruby_interpreter" ]] ; then
597
590
  unset rvm_ruby_string rvm_ruby_version
598
591
  __rvm_ruby_do
599
592
  else # all
600
593
  while read bin_line
601
594
  do # Keep this on second line damnit!
602
- if [ -x $bin_line ] ; then
595
+ if [[ -x "$bin_line" ]] ; then
603
596
  rvm_ruby_string="$(dirname $bin_line | xargs dirname | xargs basename)"
604
597
  __rvm_ruby_do
605
598
  fi
606
599
  done < <(/bin/ls $rvm_path/*/bin/ruby 2> /dev/null)
607
600
  fi
608
601
 
609
- if [ ! -z "$rvm_summary_flag" ] ; then __rvm_summary ; fi
610
- if [ ! -z "$rvm_yaml_flag" ] ; then __rvm_yaml ; fi
611
- if [ ! -z "$rvm_json_flag" ] ; then __rvm_json ; fi
602
+ if [[ ! -z "$rvm_summary_flag" ]] ; then __rvm_summary ; fi
603
+ if [[ ! -z "$rvm_yaml_flag" ]] ; then __rvm_yaml ; fi
604
+ if [[ ! -z "$rvm_json_flag" ]] ; then __rvm_json ; fi
612
605
 
613
606
  __rvm_state
614
607
 
@@ -618,14 +611,14 @@ function __rvm_do {
618
611
  function __rvm_summary {
619
612
  export successes errors statuses
620
613
  summary="\nSummary:\n\n"
621
- if [ ${#successes[*]} -gt 0 ] ; then
614
+ if [[ ${#successes[*]} -gt 0 ]] ; then
622
615
  summary="$summary \033[0;32m${#successes[*]} successful: $(echo "${successes[*]}" | sed 's# #, #g')\033[0m\n"
623
616
  fi
624
- if [ ${#errors[*]} -gt 0 ] ; then
617
+ if [[ ${#errors[*]} -gt 0 ]] ; then
625
618
  summary="$summary \033[0;31m${#errors[*]} errors: $(echo "${errors[*]}" | sed 's# #, #g')\033[0m\n"
626
619
  fi
627
620
  total=${#rubies[*]}
628
- if [ ! -z "$ZSH_VERSION" ] ; then array_start=1 ; else array_start=0 ; fi
621
+ if [[ ! -z "$ZSH_VERSION" ]] ; then array_start=1 ; else array_start=0 ; fi
629
622
  echo -e "$summary" | tee -a log/summary.log
630
623
  return ${#errors[*]}
631
624
  }
@@ -638,7 +631,7 @@ function __rvm_yaml {
638
631
  for var in ${errors[*]} ; do yaml="$yaml\n - $var" ; done
639
632
  yaml="$yaml\nrubies:"
640
633
  total=${#rubies[*]}
641
- if [ ! -z "$ZSH_VERSION" ] ; then array_start=1 ; else array_start=0 ; fi
634
+ if [[ ! -z "$ZSH_VERSION" ]] ; then array_start=1 ; else array_start=0 ; fi
642
635
  for (( index = $array_start ; index < $total + $array_start ; index++ )) ; do
643
636
  __rvm_log "debug" "${rubies[$index]}: ${statuses[$index]}"
644
637
  yaml="$yaml\n \"${rubies[$index]}\": ${statuses[$index]}"
@@ -657,7 +650,7 @@ function __rvm_json {
657
650
  json="$json\n \"rubies\": {"
658
651
 
659
652
  total=${#rubies[*]}
660
- if [ ! -z "$ZSH_VERSION" ] ; then array_start=1 ; else array_start=0 ; fi
653
+ if [[ ! -z "$ZSH_VERSION" ]] ; then array_start=1 ; else array_start=0 ; fi
661
654
  for (( index = $array_start ; index < $total + $array_start ; index++ )) ; do
662
655
  __rvm_log "debug" "${rubies[$index]}: ${statuses[$index]}"
663
656
  json="$json\n {\"${rubies[$index]}\": ${statuses[$index]}}"
@@ -679,12 +672,12 @@ function __rvm_benchmark {
679
672
  echo -e "\n end \nend\n" >> "$rvm_temp_path/$$.rb"
680
673
  rvm_ruby_args="$rvm_temp_path/$$.rb"
681
674
  rvm_action="ruby"
682
- if [ ! -z "$rvm_debug_flag" ] ; then echo -e "$rvm_temp_path/$$.rb:\n$(cat $rvm_temp_path/$$.rb)" ; fi
675
+ if [[ ! -z "$rvm_debug_flag" ]] ; then echo -e "$rvm_temp_path/$$.rb:\n$(cat $rvm_temp_path/$$.rb)" ; fi
683
676
  __rvm_do
684
677
  }
685
678
 
686
679
  function __rvm_irbrc {
687
- if [ -d $rvm_ruby_home -a ! -s $rvm_ruby_irbrc ] ; then
680
+ if [[ -d "$rvm_ruby_home" ]] && [[ ! -s "$rvm_ruby_irbrc" ]] ; then
688
681
  rvm_ruby_irbrc_file=$(cat <<-Config
689
682
 
690
683
  require "irb/completion" rescue nil
@@ -712,7 +705,7 @@ Config
712
705
  }
713
706
 
714
707
  function __rvm_pushpop {
715
- if [ -z "$1" ] ; then
708
+ if [[ -z "$1" ]] ; then
716
709
  popd > /dev/null 2>&1
717
710
  else
718
711
  pushd "$1" > /dev/null 2>&1
@@ -720,8 +713,8 @@ function __rvm_pushpop {
720
713
  }
721
714
 
722
715
  function __rvm_state {
723
- if [ -z "$rvm_state" ] ; then
724
- if [ -z "$(which ruby | awk /$(basename $rvm_path)/)" ] ; then
716
+ if [[ -z "$rvm_state" ]] ; then
717
+ if [[ -z "$(which ruby | awk /$(basename $rvm_path)/)" ]] ; then
725
718
  rvm_state=system
726
719
  else
727
720
  rvm_state="$(dirname $(which ruby) | xargs dirname | xargs basename)"
@@ -738,12 +731,12 @@ function __rvm_inspect {
738
731
  for binary in $rvm_ruby_args ; do
739
732
  actual_file=$(which $binary)
740
733
  __rvm_log "info" "$actual_file:"
741
- if [ ! -z "$rvm_shebang_flag" ] ; then cat $actual_file | head -n 1 ; fi
742
- if [ ! -z "$rvm_env_flag" ] ; then cat $actual_file | awk '/ENV/' ; fi
743
- if [ ! -z "$rvm_path_flag" ] ; then cat $actual_file | awk '/PATH/' ; fi
744
- if [ ! -z "$rvm_head_flag" ] ; then cat $actual_file | head -n 5 ; fi
745
- if [ ! -z "$rvm_tail_flag" ] ; then cat $actual_file | tail -n 5 ; fi
746
- if [ ! -z "$rvm_all_flag" ] ; then cat $actual_file ; fi
734
+ if [[ ! -z "$rvm_shebang_flag" ]] ; then cat $actual_file | head -n 1 ; fi
735
+ if [[ ! -z "$rvm_env_flag" ]] ; then cat $actual_file | awk '/ENV/' ; fi
736
+ if [[ ! -z "$rvm_path_flag" ]] ; then cat $actual_file | awk '/PATH/' ; fi
737
+ if [[ ! -z "$rvm_head_flag" ]] ; then cat $actual_file | head -n 5 ; fi
738
+ if [[ ! -z "$rvm_tail_flag" ]] ; then cat $actual_file | tail -n 5 ; fi
739
+ if [[ ! -z "$rvm_all_flag" ]] ; then cat $actual_file ; fi
747
740
  done
748
741
  }
749
742
 
@@ -759,7 +752,7 @@ function __rvm_readline_install {
759
752
  __rvm_fetch "ftp://ftp.gnu.org/gnu/readline/$package-$version.$archive_format"
760
753
  __rvm_run "$package/extract" "tar zxf $rvm_archives_path/$package-$version.$archive_format -C $rvm_src_path" "Extracting $package-$version.$archive_format"
761
754
  cd "$rvm_src_path/$package-$version"
762
- if [ "Darwin" = "$(uname)" ] ; then
755
+ if [[ "Darwin" = "$(uname)" ]] ; then
763
756
  #sdk=$(ls -t /Developer/SDKs/ | head -n 1)
764
757
  #CFLAGS="-isysroot /Developer/SDKs/$sdk -arch i386 -arch x86_64"
765
758
  #LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/$sdk -arch i386 -arch x86_64"
@@ -830,15 +823,14 @@ function __rvm_ncurses_install {
830
823
  }
831
824
 
832
825
  __rvm_make_flags() {
833
- PATH=.rvm/usr/bin:$PATH ; export PATH
834
- if [ "Darwin" = "$(uname)" ] ; then
826
+ PATH=${rvm_path}/usr/bin:$PATH ; export PATH
827
+ if [[ "Darwin" = "$(uname)" ]] ; then
835
828
  sdk="$(/bin/ls -t /Developer/SDKs/ | head -n 1)"
836
- if [ "Darwin" = "$(uname)" ] ; then
837
- if [[ "$(sw_vers -productVersion)" =~ ^10.6 ]] ; then
838
- rvm_archflags="-arch x86_64"
829
+ if [[ "Darwin" = "$(uname)" ]] ; then
830
+ rvm_archflags="-arch $(uname -m)"
831
+ if [[ "-arch x86_64" = "$rvm_archflags" ]] ; then
839
832
  openssl_os="os/compiler darwin64-x86_64-cc"
840
833
  else
841
- rvm_archflags="-arch i386"
842
834
  openssl_os="os/compiler darwin-i386-cc"
843
835
  fi
844
836
  fi
@@ -849,9 +841,9 @@ __rvm_make_flags() {
849
841
  }
850
842
 
851
843
  __rvm_monitor() {
852
- if [ -d test/ ] ; then
844
+ if [[ -d "test/" ]] ; then
853
845
  :
854
- elif [ -d spec/ ] ; then
846
+ elif [[ -d "spec/" ]] ; then
855
847
  :
856
848
  fi
857
849
  }
@@ -860,7 +852,7 @@ __rvm_monitor() {
860
852
  # Actual Utility functions.
861
853
  #
862
854
  timestamp() {
863
- if [ "Darwin" = "$(uname)" ] ; then
855
+ if [[ "Darwin" = "$(uname)" ]] ; then
864
856
  echo $(stat -c "%Y" $1)
865
857
  else
866
858
  echo $(stat -f "%m" $1)