scripts/utility in rvm-0.0.73 vs scripts/utility in rvm-0.0.74

- old
+ new

@@ -31,11 +31,11 @@ IRBRC: "$IRBRC" Info unset full_version } -function __rvm_debug { +__rvm_debug() { __rvm_log "debug" "PATH:\n$(echo $PATH | awk -F":" '{print $1":"$2":"$3":"$4":"$5}')" __rvm_log "debug" "uname -a: $(uname -a)" if [[ "Darwin" = "$(uname)" ]] ; then __rvm_log "debug" "uname -r: $(uname -r)" @@ -66,11 +66,11 @@ fi } # Logging functions based on level # TODO: Allow specification of a base file name to output to. -function __rvm_log { +__rvm_log() { if [[ ! -z "$2" ]] ; then level=$1 ; shift ; else level="info" ; fi message=$1 case "$level" in debug) shift ; ((rvm_debug_flag)) && echo -e "$(tput setaf 5)<d>$(tput sgr0) $message $(tput setaf 5)</d> $(tput sgr0) " @@ -90,23 +90,23 @@ eval "index=\$((\${#${array}[*]} + $__shell_array_start))" eval "${array}[${index}]=${item}" unset array item } -function __rvm_clean_path { +__rvm_clean_path() { PATH=$(echo $PATH | tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' | tr -s '\n' ':' | sed 's#:$##') export PATH } -function __rvm_remove_rvm_from_path { +__rvm_remove_rvm_from_path() { PATH=$(echo $PATH | tr -s ':' '\n' | grep -v "\.rvm" | tr -s '\n' ':' | sed 's#:$##') export PATH } -function __rvm_gi { gem install -q --no-rdoc --no-ri $* ; } +__rvm_gi() { gem install -q --no-rdoc --no-ri $* ; } -function __rvm_run { +__rvm_run() { log_file_name="$1" ; command="$2" ; message="$3" rvm_ruby_log_path="${rvm_ruby_log_path:-$rvm_path/log}" mkdir -p $(dirname "$rvm_ruby_log_path/$log_file_name.log") if [[ ! -z "$message" ]] ; then __rvm_log "info" "$message" ; fi @@ -122,33 +122,33 @@ 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_ruby_configure 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_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 + 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 } # TODO: root user loadng of /etc/rvmrc -function __rvm_load_rvmrc { +__rvm_load_rvmrc() { if [[ -s ~/.rvmrc ]] ; then source ~/.rvmrc ; fi } -function __rvm_bin_scripts { +__rvm_bin_scripts() { for rvm_ruby_binary in $(\ls $rvm_path/*/bin/ruby 2> /dev/null) ; do if [[ -x "$rvm_ruby_binary" ]] ; then rvm_ruby_string=$(dirname "$rvm_ruby_binary" | xargs dirname | xargs basename) __rvm_select __rvm_bin_script fi done } -function __rvm_bin_script { +__rvm_bin_script() { if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi ruby_wrapper=$(cat <<RubyWrapper #!/bin/bash GEM_HOME=$rvm_ruby_gem_home ; export GEM_HOME @@ -163,11 +163,11 @@ echo "$ruby_wrapper" > $rvm_path/bin/$rvm_ruby_package_name unset ruby_wrapper chmod +x $rvm_path/bin/$rvm_ruby_package_name } -function __rvm_fetch { +__rvm_fetch() { __rvm_pushpop $rvm_archives_path if [[ -z "$1" ]] ; then log "fail" "BUG: __rvm_fetch called without an argument :/" ; return 1 ; fi archive=$(basename "$1") ; downlaod=1 __rvm_log "debug" "Fetching $archive" # Check first if we have the correct archive @@ -219,11 +219,11 @@ unset archive unset download return $result } -function __rvm_load_defaults { +__rvm_load_defaults() { if [[ ! -s "$rvm_path/system" ]] ; then for variable in RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME ; do eval value=\$${variable} if [[ -z "$value" ]] ; then echo "unset ${variable}" >> $rvm_path/system @@ -256,11 +256,11 @@ fi fi fi } -function __rvm_reset { +__rvm_reset() { PATH=$(echo $PATH | tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -) PATH=$rvm_bin_path:$PATH ; export PATH for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do unset $variable ; done @@ -275,11 +275,11 @@ done ; unset system_config variable rm -f $rvm_path/bin/ruby $rvm_path/bin/gem $rvm_path/bin/rake $rvm_path/bin/irb $rvm_path/bin/default* } -function __rvm_implode { +__rvm_implode() { while : ; do __rvm_log "warn" "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')" read response if [[ "yes" = "$response" ]] ; then if [[ "/" = "$rvm_path" ]] ; then @@ -299,31 +299,31 @@ break fi done } -function __rvm_gemdir { +__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 } -function __rvm_source_dir { +__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 echo "$rvm_ruby_src_path" fi } # clones from source implementation/version to default # TODO: Merge this into 'rvm sync' -function __rvm_gemdup { +__rvm_gemdup() { if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select $* ; fi __rvm_log "debug" "$rvm_ruby_interpreter" if [[ "default" = "$rvm_ruby_interpreter" ]] ; then # TODO: ~/.rvm/default first, then system user rvm_source_gem_path="$rvm_system_user_gem_path" @@ -336,11 +336,11 @@ rvm_source_gem_path=${rvm_ruby_gem_home/$rvm_ruby_interpreter/$rvm_ruby_version} fi __rvm_gem_sync } -function __rvm_gem_sync { +__rvm_gem_sync() { if [[ ! -z "$rvm_source_gem_path" ]] ; then for rvm_gem_name_version in $rvm_source_gem_path/gems/* ; do rvm_gem_name="${rvm_gem_name_version%-*}" rvm_gem_version="${rvm_gem_name_version##*-}" if [[ -d $GEM_HOME/gems/$rvm_gem_name_version ]] ; then @@ -489,11 +489,11 @@ fi fi ; unset current_ruby version selected fi } -function __rvm_initialize { +__rvm_initialize() { rvm_fetch=$(which curl) if [[ $? -ne 0 ]] ; then __rvm_log "fail" "rvm requires curl, which does not seem to exist in your path :(" else rvm_fetch="$rvm_fetch -O -L --create-dirs -C - " # -s for silent @@ -663,11 +663,11 @@ __rvm_state return ${#errors[*]} } -function __rvm_summary { +__rvm_summary() { export successes errors statuses summary="\nSummary:\n\n" if [[ ${#successes[*]} -gt 0 ]] ; then summary="$summary \033[0;32m${#successes[*]} successful: $(echo "${successes[*]}" | sed 's# #, #g')\033[0m\n" fi @@ -678,11 +678,11 @@ if [[ ! -z "$ZSH_VERSION" ]] ; then array_start=1 ; else array_start=0 ; fi echo -e "$summary" | tee -a log/summary.log return ${#errors[*]} } -function __rvm_yaml { +__rvm_yaml() { export successes errors statuses yaml="totals:\n rubies: ${#rubies[*]}\n successes: ${#successes[*]}\n errors: ${#errors[*]}\nsuccesses:" for var in ${successes[*]} ; do yaml="$yaml\n - $var" ; done yaml="$yaml\nerrors:" for var in ${errors[*]} ; do yaml="$yaml\n - $var" ; done @@ -697,11 +697,11 @@ echo -e "$yaml" | tee -a log/summary.yaml return ${#errors[*]} } -function __rvm_json { +__rvm_json() { json="{" json="$json\n \"totals\": { \"rubies\": ${#rubies[*]}, \"successes\": ${#successes[*]}, \"errors\": ${#errors[*]}}," json="$json\n \"successful\": [ "$(echo ${successes[*]} | sed 's# #", "#g')" ]," json="$json\n \"errors\": [ "$(echo ${errors[*]} | sed 's# #", "#g')" ]," json="$json\n \"rubies\": {" @@ -719,11 +719,11 @@ echo -e "$json" | tee -a log/summary.json return ${#errors[*]} } -function __rvm_benchmark { +__rvm_benchmark() { code="require \"benchmark\" \n Benchmark.bmbm do |benchmark| \n benchmark.report(\"${rvm_ruby_file}\") do \n" echo -e "$code" > "$rvm_temp_path/$$.rb" unset code cat $rvm_ruby_file >> "$rvm_temp_path/$$.rb" echo -e "\n end \nend\n" >> "$rvm_temp_path/$$.rb" @@ -732,26 +732,26 @@ rvm_action="ruby" if [[ ! -z "$rvm_debug_flag" ]] ; then echo -e "$rvm_temp_path/$$.rb:\n$(cat $rvm_temp_path/$$.rb)" ; fi __rvm_do } -function __rvm_irbrc { +__rvm_irbrc() { # Create the irbrc for the currently selected ruby installation. if [[ -d "$rvm_ruby_home" ]] && [[ ! -s "$rvm_ruby_irbrc" ]] ; then cp $rvm_path/scripts/irbrc $rvm_ruby_irbrc fi } -function __rvm_pushpop { +__rvm_pushpop() { if [[ -z "$1" ]] ; then popd > /dev/null 2>&1 else pushd "$1" > /dev/null 2>&1 fi } -function __rvm_state { +__rvm_state() { if [[ -z "$rvm_state" ]] ; then if [[ -z "$(which ruby | awk /$(basename $rvm_path)/)" ]] ; then rvm_state=system else rvm_state="$(dirname $(which ruby) | xargs dirname | xargs basename)" @@ -762,11 +762,11 @@ __rvm_use unset rvm_state fi } -function __rvm_inspect { +__rvm_inspect() { for binary in $rvm_ruby_args ; do actual_file=$(which $binary) __rvm_log "info" "$actual_file:" if [[ ! -z "$rvm_shebang_flag" ]] ; then cat $actual_file | head -n 1 ; fi if [[ ! -z "$rvm_env_flag" ]] ; then cat $actual_file | awk '/ENV/' ; fi @@ -778,11 +778,11 @@ } # # ruby supporting libraries: # -function __rvm_readline_install { +__rvm_readline_install() { __rvm_make_flags __rvm_pushpop $rvm_src_path package="readline" ; version="5.2" ; archive_format="tar.gz" # TODO: Figure out how to list, grab and apply the patches __rvm_log "info" "Retrieving $package-$version.$archive_format" @@ -801,11 +801,11 @@ __rvm_run "$package/make" "/usr/bin/make $rvm_make_flags" "Compiling $package" __rvm_run "$package/make.install" "/usr/bin/make install" "Installing $package to $rvm_path/usr" __rvm_pushpop } -function __rvm_iconv_install { +__rvm_iconv_install() { __rvm_make_flags __rvm_pushpop $rvm_src_path package="libiconv" ; version=1.13.1 ; archive_format="tar.gz" __rvm_log "info" "Retrieving $package-$version.$archive_format" __rvm_fetch "http://ftp.gnu.org/pub/gnu/libiconv/$package-$version.$archive_format" @@ -815,11 +815,11 @@ __rvm_run "$package/make" "/usr/bin/make $rvm_make_flags" "Compiling $package" __rvm_run "$package/make.install" "/usr/bin/make install" "Installing $package to $rvm_path/usr" __rvm_pushpop } -function __rvm_openssl_install { +__rvm_openssl_install() { __rvm_make_flags if match "$rvm_archflags" "x86_64" ; then openssl_os="os/compiler darwin64-x86_64-cc" else openssl_os="os/compiler darwin-i386-cc" @@ -834,11 +834,11 @@ __rvm_run "$package/make" "/usr/bin/make $rvm_make_flags" "Compiling $package" __rvm_run "$package/make.install" "/usr/bin/make install" "Installing $package to $rvm_path/usr" __rvm_pushpop } -function __rvm_zlib_install { +__rvm_zlib_install() { __rvm_make_flags __rvm_pushpop $rvm_src_path package="zlib" ; version="1.2.3" ; archive_format="tar.gz" __rvm_log "info" "Retrieving $package-$version.$archive_format" __rvm_fetch "http://www.zlib.net/$package-$version.tar.gz" @@ -848,11 +848,11 @@ __rvm_run "$package/make" "/usr/bin/make $rvm_make_flags" "Compiling $package" __rvm_run "$package/make.install" "/usr/bin/make install" "Installing $package to $rvm_path/usr" __rvm_pushpop } -function __rvm_ncurses_install { +__rvm_ncurses_install() { __rvm_make_flags __rvm_pushpop $rvm_src_path package="ncurses" ; version="5.7" ; archive_format="tar.gz" __rvm_log "info" "Retrieving $package" __rvm_fetch "ftp://invisible-island.net/ncurses/ncurses.tar.gz" @@ -873,12 +873,12 @@ # The user may override via setting rvm_archflags in ~/.rvmrc rvm_archflags="-arch $(uname -m )" fi if [[ "-arch x86_64" = "$rvm_archflags" ]] ; then - rvm_ruby_configure="${rvm_ruby_configure} --build=x86_64-apple-darwin$(uname -r) --host=x86_64-apple-darwin$(uname -r)" + rvm_ruby_configure_flags="${rvm_ruby_configure_flags} --build=x86_64-apple-darwin$(uname -r) --host=x86_64-apple-darwin$(uname -r)" elif [[ "-arch i386" = "$rvm_archflags" ]] ; then - rvm_ruby_configure="${rvm_ruby_configure} --build=i386-apple-darwin$(uname -r) --host=i386-apple-darwin$(uname -r)" + 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