scripts/utility in rvm-0.0.75 vs scripts/utility in rvm-0.0.76

- old
+ new

@@ -128,11 +128,11 @@ unset log_file command } __rvm_cleanup_variables() { __rvm_unset_ruby_variables - unset rvm_ruby_selected_flag rvm_action rvm_irbrc_file rvm_src_path rvm_path rvm_prefix_path rvm_gem_path rvm_command rvm_error_message rvm_gem_set_name rvm_url rvm_config_path rvm_bin_path rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_load_flag rvm_dump_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_log_path rvm_file_name rvm_benchmark_flag + unset rvm_ruby_selected_flag rvm_action rvm_irbrc_file rvm_src_path rvm_path rvm_prefix_path rvm_gem_path rvm_command rvm_error_message rvm_gem_set_name rvm_url rvm_config_path rvm_bin_path rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_load_flag rvm_dump_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_log_path rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag } __rvm_unset_ruby_variables() { unset rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_ruby_binary rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_ruby_selected_flag rvm_ruby_string rvm_ruby_string rvm_ruby_src_path rvm_ruby_repo_url rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_head_flag rvm_ruby_configure_flags rvm_ruby_configure } @@ -305,19 +305,10 @@ break fi done } -__rvm_gemdir() { - if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi - if [[ ! -z "$GEM_HOME" ]] ; then - echo "$GEM_HOME" - else - gem env gemdir - fi -} - __rvm_source_dir() { if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi if [[ -z "$rvm_ruby_src_path" ]] ; then __rvm_log "fail" "No source directory exists for the default implementation." else @@ -397,103 +388,95 @@ if [[ "Darwin" = "$(uname)" ]] ; then echo -e "macruby-nightly (macruby-nightly, the default)\nmacruby-head" fi else current_ruby="$(which ruby | xargs dirname | xargs dirname | xargs basename 2> /dev/null)" - echo -e "\nruby:\n" 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 "=> $version : $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" selected="1" else - echo -e " $version : $string" + echo -e " $(tput setaf 2)$version$(tput sgr0): $string" fi done ; unset version - echo -e "\nree:\n" 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 "=> $version : $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" selected="1" else - echo -e " $version : $string" + echo -e " $(tput setaf 2)$version$(tput sgr0): $string" fi done ; unset version - echo -e "\nmput:\n" 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 "=> $version : $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" selected="1" else - echo -e " $version : $string" + echo -e " $(tput setaf 2)$version$(tput sgr0): $string" fi done ; unset version - echo -e "\njruby:\n" 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 "=> $version : $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" selected="1" else - echo -e " $version : $string" + echo -e " $(tput setaf 2)$version$(tput sgr0): $string" fi done ; unset version - echo -e "\nrbx:\n" # 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 "=> $version : $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" selected="1" else - echo -e " $version : $string" + echo -e " $(tput setaf 2)$version$(tput sgr0): $string" fi fi done ; unset version if [[ "Darwin" = "$(uname)" ]] ; then - echo -e "\nmacruby:\n" 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 "=> $version : $string" + echo -e "=> $(tput setaf 2)$version$(tput sgr0): $string" selected="1" else - echo -e " $version : $string" + echo -e " $(tput setaf 2)$version$(tput sgr0): $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 - echo -e "\ndefault:\n" string=$($rvm_path/$version/bin/ruby -v) if [[ "$version" = "$current_ruby" ]] ; then - echo -e "=> $version : $string" + echo -e "=> $(tput setaf 3)(default)$(tput sgr0) $(tput setaf 2)$version$(tput sgr0): $string" selected="1" else - echo -e " $version : $string" + echo -e " $(tput setaf 3)(default)$(tput sgr0) $(tput setaf 2)$version$(tput sgr0): $string" fi fi ; unset version fi - echo -e "\nsystem:\n" system_version=$(rvm system ; ruby -v 2> /dev/null) if [[ ! -z "$system_version" ]] ; then if [[ "$($(which ruby) -v)" = "$system_version" ]] ; then - echo -e "=> $system_version\n" + echo -e "=> $(tput setaf 2)system$(tput sgr0): $system_version\n" else - echo -e " $system_version\n" + echo -e " $(tput setaf 2)system$(tput sgr0): $system_version\n" fi fi ; unset current_ruby version selected fi } @@ -501,11 +484,15 @@ # TODO: Sanitize user input, ensure that there is a / a the end... if [[ "root" = "$(whoami)" ]] ; then rvm_prefix_path="${rvm_prefix_path:-/usr/local/}" rc_files="/etc/profile /etc/zshenv" else - rvm_prefix_path="${rvm_prefix_path:-"$HOME/."}" + if [[ -f "$HOME/.rvm/scripts/rvm" ]] ; then + rvm_prefix_path="${rvm_prefix_path:-"$HOME/."}" + else + rvm_prefix_path="${rvm_prefix_path:-"/usr/local/"}" + fi rc_files="$HOME/.bash_profile $HOME/.bashrc $HOME/.zshrc" fi if [[ "${rvm_prefix_path#${rvm_prefix_path%?}}" = '.' ]] || [[ "${rvm_prefix_path#${rvm_prefix_path%?}}" = '/' ]] ; then rvm_path="${rvm_prefix_path}rvm" @@ -600,11 +587,11 @@ # TODO: the else case below should be run if $rvm_ruby_args =~ /\.rb$/ if [[ "ruby" = "$binary" ]] && [[ "$rvm_benchmark_flag" -ne 1 ]] ; then if match "$rvm_ruby_args" "\.rb$" ; then if [[ -z "$prefix" ]] ; then prefix="-S" ; fi if ! match "$rvm_ruby_args" "$prefix" ; then - rvm_ruby_args="$prefix '$rvm_ruby_args'" + rvm_ruby_args="$prefix $rvm_ruby_args" fi fi rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_require -I$load_path $rvm_ruby_args" elif [[ "gem" = "$binary" ]] && match "$rvm_ruby_args" 'install' ; then rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_args --no-rdoc --no-ri" @@ -648,11 +635,11 @@ done elif [[ ! -z "$rvm_ruby_interpreter" ]] ; then unset rvm_ruby_string rvm_ruby_version __rvm_ruby_do else # all - while read bin_line + while read -r bin_line do # Keep this on second line damnit! if [[ -x "$bin_line" ]] ; then rvm_ruby_string="$(dirname $bin_line | xargs dirname | xargs basename)" __rvm_ruby_do fi @@ -867,56 +854,61 @@ __rvm_pushpop } __rvm_make_flags() { PATH=${rvm_path}/usr/bin:$PATH ; export PATH + # This is only an issue with Darwin :/ if [[ "Darwin" = "$(uname)" ]] ; then + # ls /usr/lib/gcc/i686-apple-darwin10 - if [[ -z "$rvm_archflags" ]] ; then - # Build for the archtecture that is reported. - # The user may override via setting rvm_archflags in ~/.rvmrc - rvm_archflags="-arch $(uname -m )" + # Set the build & host type + if [[ $(sysctl hw.cpu64bit_capable | awk '{print $2}') = 1 ]] ; then # we could also use: sysctl hw.optional.x86_64 + # 64 bit capable + if [[ "-arch x86_64" = "$rvm_archflags" ]] ; then + : + #rvm_ruby_configure_flags="${rvm_ruby_configure_flags}" #" --build=i686-apple-darwin$(uname -r) --host=i686-apple-darwin$(uname -r)" + elif [[ "-arch i386" = "$rvm_archflags" ]] ; then + : + #rvm_ruby_configure_flags="${rvm_ruby_configure_flags}" #" --build=i386-apple-darwin$(uname -r) --host=i386-apple-darwin$(uname -r)" + else + rvm_archflags="-arch x86_64" + #rvm_ruby_configure_flags="${rvm_ruby_configure_flags}" #" --build=i686-apple-darwin$(uname -r) --host=i686-apple-darwin$(uname -r)" + fi + else + # 32 bit capable only + if [[ -z "$rvm_archflags" ]] ; then rvm_archflags="-arch i386" ; fi + #rvm_ruby_configure_flags="${rvm_ruby_configure_flags}" #" --build=i386-apple-darwin$(uname -r) --host=i386-apple-darwin$(uname -r)" fi + ARCHFLAGS="$rvm_archflags" ; export ARCHFLAGS - if [[ "-arch x86_64" = "$rvm_archflags" ]] ; then - rvm_ruby_configure_flags="${rvm_ruby_configure_flags} --build=i686-apple-darwin$(uname -r) --host=i686-apple-darwin$(uname -r)" - elif [[ "-arch i386" = "$rvm_archflags" ]] ; then - rvm_ruby_configure_flags="${rvm_ruby_configure_flags} --build=i386-apple-darwin$(uname -r) --host=i386-apple-darwin$(uname -r)" - fi - - if [[ -z "$rvm_sdk" ]] ; then - rvm_sdk="$(basename -a /Developer/SDKs/* | sort | tail -n 1)" - fi - + # Use the latest sdk available. + if [[ -z "$rvm_sdk" ]] ; then rvm_sdk="$(basename -a /Developer/SDKs/* | awk '/^M/' | sort | tail -n 1)" ; fi CFLAGS="-isysroot /Developer/SDKs/$rvm_sdk $rvm_archflags" ; export CFLAGS LDFLAGS="-Wl,-syslibroot /Developer/SDKs/$rvm_sdk $rvm_archflags" ; export LDFLAGS # CXXFLAGS="-mmacosx-version-min="$(sw_vers -productVersion | awk -F'.' '{print $1"."$2}')" -isysroot /Developer/SDKs/$rvm_sdk " ; export CXXFLAGS - ARCHFLAGS="$rvm_archflags" ; export ARCHFLAGS 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 - test_files=($(\ls test/**/*_test.rb)) - for file in "${test_files[@]}"; do + while read -r line ; do if [[ $(timestamp $file) -gt $timestamp ]] ; then - array_push $changed_test_files + array_push $changed_test_files $file fi - done + done < <($(\ls test/**/*_test.rb)) fi if [[ -d "spec/" ]] ; then - spec_files=($(\ls spec/**/*_spec.rb)) - for file in "${spec_files[@]}"; do + while read -r line ; do if [[ $(timestamp $file) -gt $timestamp ]] ; then - array_push $changed_spec_files + array_push $changed_spec_files $file fi - done + 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