scripts/utility in rvm-0.0.81 vs scripts/utility in rvm-0.0.82

- old
+ new

@@ -99,11 +99,11 @@ touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :( 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" if [[ -z "$rvm_niceness" ]] || [[ "0" = "$rvm_niceness" ]] ; then eval "$command" >> "$rvm_ruby_log_path/$log_file_name.log" 2>> "$rvm_ruby_log_path/$log_file_name.error.log" else - eval "nice -n $rvm_niceness \$($command)" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log + eval "nice -n $rvm_niceness $command" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log fi if [[ $? -gt 0 ]] ; then $rvm_scripts_path/log "error" "Error running '$command', please check $rvm_ruby_log_path/$log_file_name.error.log" ; __rvm_pushpop ; return 1 ; fi unset log_file command } @@ -258,92 +258,92 @@ else current_ruby="$(which ruby | xargs dirname | xargs dirname | xargs basename 2> /dev/null)" for version in $(\ls -l $rvm_path/ 2> /dev/null | awk '/ ruby-[1-2].*/ { print $NF }') ; do string=$($rvm_path/$version/bin/ruby -v) if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" selected="1" else - echo -e " $(tput setaf 2)$version$(tput sgr0): $string" + echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" fi done ; unset version for version in $(\ls $rvm_path/ 2> /dev/null | awk '/ree-.*/ { print $NF }') ; do string="$($rvm_path/$version/bin/ruby -v | tr "\n" ' ' )" if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" selected="1" else - echo -e " $(tput setaf 2)$version$(tput sgr0): $string" + echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" fi done ; unset version for version in $(\ls $rvm_path/ 2> /dev/null | awk '/mput-.*/ { print $NF }') ; do string="$($rvm_path/$version/bin/ruby -v | tr "\n" ' ' )" if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" selected="1" else - echo -e " $(tput setaf 2)$version$(tput sgr0): $string" + echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" fi done ; unset version for version in $(\ls $rvm_path/ 2> /dev/null | awk '/jruby-.*/ { print $NF }') ; do string=$($rvm_path/$version/bin/ruby -v) if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" selected="1" else - echo -e " $(tput setaf 2)$version$(tput sgr0): $string" + echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" fi done ; unset version # for version in $(\ls $rvm_path/ 2> /dev/null | awk '/rbx-.*/ { print $NF }') ; do for version in "rbx-head" ; do if [[ -f "$rvm_path/$version/bin/ruby" ]] ; then string="$($rvm_path/$version/bin/ruby -v | tr "\n" ' ' )" if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" selected="1" else - echo -e " $(tput setaf 2)$version$(tput sgr0): $string" + echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" fi fi done ; unset version if [[ "Darwin" = "$(uname)" ]] ; then for version in $(\ls $rvm_path/ 2> /dev/null | awk '/macruby-.*/ { print $NF }') ; do string="$($rvm_path/$version/bin/ruby -v | tr "\n" ' ' )" if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" selected="1" else - echo -e " $(tput setaf 2)$version$(tput sgr0): $string" + echo -e " $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" fi done ; unset version fi if [[ -f "$rvm_path/default" ]] && [[ -s $rvm_path/default ]] ; then version=$(grep '^MY_RUBY_HOME' $rvm_path/default | awk -F"'" '{print $2}' | xargs basename) if [[ ! -z "$version" ]] ; then string=$($rvm_path/$version/bin/ruby -v) if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $(tput setaf 3)(default)$(tput sgr0) $(tput setaf 2)$version$(tput sgr0): $string" + echo -e "=> $(tput setaf 3)(default)$(tput sgr0) $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" selected="1" else - echo -e " $(tput setaf 3)(default)$(tput sgr0) $(tput setaf 2)$version$(tput sgr0): $string" + echo -e " $(tput setaf 3)(default)$(tput sgr0) $(tput setaf 2)$version$(tput sgr0) ( ruby -v # => $string) )" fi fi ; unset version fi system_version=$(rvm system ; ruby -v 2> /dev/null) if [[ ! -z "$system_version" ]] ; then if [[ "$($(which ruby) -v)" = "$system_version" ]] ; then - echo -e "=> $(tput setaf 2)system$(tput sgr0): $system_version\n" + echo -e "=> $(tput setaf 2)system$(tput sgr0) ( ruby -v # => $system_version )\n" else - echo -e " $(tput setaf 2)system$(tput sgr0): $system_version\n" + echo -e " $(tput setaf 2)system$(tput sgr0) ( ruby -v # => $system_version )\n" fi fi ; unset current_ruby version selected fi } @@ -366,10 +366,11 @@ __rvm_version __rvm_update_rvm fi if [[ ! -z "$rvm_bin_flag" ]] ; then __rvm_bin_scripts ; fi if [[ ! -z "$rvm_rubygems_flag" ]] ; then __rvm_rubygems_setup ; fi + __rvm_hook "after_update" } __rvm_update_rvm() { mkdir -p "$rvm_src_path" __rvm_pushpop "$rvm_src_path" @@ -489,10 +490,12 @@ if [[ ! -z "$rvm_yaml_flag" ]] ; then __rvm_yaml ; fi if [[ ! -z "$rvm_json_flag" ]] ; then __rvm_json ; fi __rvm_state + __rvm_hook "after_do" + return ${#errors[*]} } __rvm_summary() { export successes errors statuses @@ -747,67 +750,14 @@ # CXXFLAGS="-mmacosx-version-min="$(sw_vers -productVersion | awk -F'.' '{print $1"."$2}')" -isysroot /Developer/SDKs/$rvm_sdk " ; export CXXFLAGS fi fi } -__rvm_monitor() { - if [[ -d "test/" ]] ; then test_timestamp=$(timestamp "test/") ; fi - if [[ -d "spec/" ]] ; then spec_timestamp=$(timestamp "spec/") ; fi - while : ; do - changed_test_files=() ; changed_spec_files=() - - if [[ -d "test/" ]] ; then - while read -r line ; do - if [[ $(timestamp $file) -gt $timestamp ]] ; then - array_push $changed_test_files $file - fi - done < <($(\ls test/**/*_test.rb)) +__rvm_hook() { + if [[ ! -z "$1" ]] ; then + if [[ -s "$rvm_hooks_path/$1" ]] ; then + if [[ "$rvm_verbose_flag" -eq 1 ]] || [[ "$rvm_debug_flag" -eq 1 ]] ; then $rvm_scripts_path/log "info" "running hook $1" ; fi + source "$rvm_hooks_path/$1" fi - - if [[ -d "spec/" ]] ; then - while read -r line ; do - if [[ $(timestamp $file) -gt $timestamp ]] ; then - array_push $changed_spec_files $file - fi - done < <($(\ls spec/**/*_spec.rb)) - fi - if [[ $(array_length $changed_test_files) -gt 0 ]] ; then - testrb "${myarray[*]}" - fi - if [[ $(array_length $changed_spec_files) -gt 0 ]] ; then - spec "${myarray[*]}" - fi - done -} - -# -# Actual Utility functions. -# -timestamp() { - if [[ "Darwin" = "$(uname)" ]] ; then - echo $(stat -f "%m" $1) - else - echo $(stat -c "%Y" $1) fi } -# Usage: contains "a_string" "${an_array[@]}" -contains() { - local pattern="$1" ; shift - local index list - list=("$@") - for index in "${!list[@]}" ; do - [[ ${list[index]} = $pattern ]] && { echo $index ; return 0 ; } - done - echo -1 ; return 1 -} - -array_length() { - array=$1 ; return "${#array[*]}" -} - -array_push() { - array=$1 ; shift ; item=$2 - # TODO: allow loop over more arguments. - eval "index=\$((\${#${array}[*]} + $__array_start))" - eval "${array}[${index}]=${item}" -}