scripts/utility in rvm-1.0.6 vs scripts/utility in rvm-1.0.7

- old
+ new

@@ -12,14 +12,10 @@ __shell_array_start=0 # bash array indexes are 0 based. fi ; export __shell_array_start } __rvm_teardown() { - declare rvm_dump_environment_flag=${rvm_dump_environment_flag:-0} - declare rvm_clang_flag=${rvm_clang_flag:-0} - declare rvm_prior_cc=${rvm_prior_cc:-""} - if [[ -n "${ZSH_VERSION:-""}" ]] ; then if [[ "$rvm_zsh_clobber" -eq 0 ]] ; then setopt noclobber fi ; unset rvm_zsh_clobber else @@ -28,22 +24,21 @@ # Ruby strings are scoped to their action. # Hence, we ensure we remove them at in # the cleanup phase. # Clean up after CC switch - if [[ -n "$rvm_clang_flag" ]] ; then - if [[ -n "$rvm_prior_cc" ]] ; then + if [[ ${rvm_clang_flag:-0} -gt 0 ]] ; then + if [[ -n "${rvm_prior_cc:-""}" ]] ; then export CC="$rvm_prior_cc" else unset CC fi - unset rvm_prior_cc fi - unset rvm_ruby_strings + unset rvm_ruby_strings rvm_head_flag rvm_prior_cc - [[ $rvm_dump_environment_flag -eq 1 ]] && __rvm_dump_environment + [[ ${rvm_dump_environment_flag:-0} -eq 1 ]] && __rvm_dump_environment return 0 } # Dump the current environment to a file. @@ -61,11 +56,11 @@ if [[ "$dump_environment_type" == "atheis"* ]] && [[ -f "$dump_environment_file" ]] ; then # TODO: Query Darcy about the ln. \rm -f "$dump_environment_file" && ln -s /dev/null "$dump_environment_file" >/dev/null 2>&1 else - "$rvm_scripts_path/environment-convertor" "$dump_environment_type" "$(__rvm_environment_identifier)" > "$dump_environment_file" + "$rvm_path/scripts/environment-convertor" "$dump_environment_type" "$(__rvm_environment_identifier)" > "$dump_environment_file" if [[ "$?" -gt 0 && -f "$dump_environment_file" ]] ; then \rm -f "$dump_environment_file" fi fi fi @@ -102,15 +97,15 @@ key=${1:-""} variable=${2:-""} if [[ -f "$rvm_config_path/user" ]] ; then - value="$($rvm_scripts_path/db "$rvm_config_path/user" "$key")" + value="$($rvm_path/scripts/db "$rvm_config_path/user" "$key")" fi if [[ -z "$value" ]] ; then - value="$($rvm_scripts_path/db "$rvm_config_path/db" "$key")" + value="$($rvm_path/scripts/db "$rvm_config_path/db" "$key")" fi if [[ -n "$value" ]] ; then if [[ -z "$variable" ]] ; then echo $value @@ -161,11 +156,11 @@ } __rvm_warn_on_rubyopt() { if [[ -n "${RUBYOPT:-""}" ]]; then - "$rvm_scripts_path"/log "warn" \ + "$rvm_path/scripts"/log "warn" \ "Please note: You have the RUBYOPT environment variable set and this may interfere with normal rvm operations. We sugges unsetting it." return 1 else return 0 fi @@ -198,24 +193,10 @@ eval "${array}[${index}]=${item}" return 0 } -__rvm_set_path_variable() { - - if [[ -d "$1" ]] ; then - eval "${path_variable}=${1}" - - else - "$rvm_scripts_path/log" "error" \ - "'$1' is not a valid path." - unset path_variable - fi - - return 0 -} - # Clean all *duplicate* items out of the path. (keep first occurrence of each) __rvm_clean_path() { PATH="$(echo $PATH | \tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' | \tr -s '\n' ':' | sed 's#:$##')" export PATH @@ -241,14 +222,14 @@ command="${2:-""}" message="${3:-""}" if [[ -z "${rvm_ruby_log_path:-""}" ]] ; then rvm_ruby_log_path="$rvm_log_path" ; fi - if [[ -n "$message" ]] ; then "$rvm_scripts_path/log" "info" "$message" ; fi + if [[ -n "$message" ]] ; then "$rvm_path/scripts/log" "info" "$message" ; fi if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then - "$rvm_scripts_path/log" "debug" "Executing: $command" + "$rvm_path/scripts/log" "debug" "Executing: $command" fi \mkdir -p "$(dirname "$rvm_ruby_log_path/$log_file_name.log")" \touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :( @@ -263,11 +244,11 @@ fi ) local result=$? if [[ $result -gt 0 ]] ; then - "$rvm_scripts_path/log" "error" \ + "$rvm_path/scripts/log" "error" \ "Error running '$command', please check $rvm_ruby_log_path/$log_file_name*.log" fi return $result } @@ -284,14 +265,14 @@ if [[ -z "$env_name" ]]; then env_name="$(__rvm_environment_identifier)"; fi if [[ -z "$rvm_ruby_log_path" ]] ; then rvm_ruby_log_path="$rvm_log_path" ; fi - if [[ -n "$message" ]] ; then "$rvm_scripts_path/log" "info" "$message" ; fi + if [[ -n "$message" ]] ; then "$rvm_path/scripts/log" "info" "$message" ; fi if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then - "$rvm_scripts_path/log" "debug" "Executing: $command in environment "$env_name"" + "$rvm_path/scripts/log" "debug" "Executing: $command in environment "$env_name"" fi \mkdir -p "$(dirname "$rvm_ruby_log_path/$log_file_name.log")" \touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :( @@ -306,11 +287,11 @@ fi ) result=$? if [[ $result -gt 0 ]] ; then - "$rvm_scripts_path/log" "error" \ + "$rvm_path/scripts/log" "error" \ "Error running '$command' under $env_name, please check $rvm_ruby_log_path/$log_file_name*.log" fi return $result } @@ -326,10 +307,11 @@ # TODO: Should be able to... # Unset both rvm variables as well as ruby-specific variables # Preserve gemset if 'rvm_sticky' is set (persist gemset unless clear is explicitely called). __rvm_cleanse_variables() { + __rvm_unset_ruby_variables if [[ ${rvm_sticky_flag:-0} -eq 1 ]] ; then export rvm_gemset_name ; else unset rvm_gemset_name ; fi unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_import_flag rvm_export_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_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_configure_flags rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_sticky_flag rvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag rvm_docs_flag rvm_ruby_aliases rvm_patch_names rvm_clang_flag rvm_install_arguments rvm_dump_environment_flag rvm_ruby_alias @@ -351,13 +333,13 @@ # Returns the first 1.8.7-compatible (partly) ruby for use # with things like rbx etc which require a ruby be installed. __rvm_18_compat_ruby() { local rubies ruby_name - rubies=($( cd "$rvm_rubies_path" ; find * -type d -maxdepth 0 )) + rubies=($( cd "$rvm_rubies_path" ; find . -maxdepth 1 -mindepth 1 -type d )) - for ruby_name in "${rubies[@]}"; do + for ruby_name in "${rubies[@]//.\/}"; do if [[ ! -L "$rvm_rubies_path/$ruby_name" ]] ; then case $ruby_name in *1.8.*|rbx-*|ree-*) rubies="$rubies $ruby_name" ;; @@ -374,13 +356,13 @@ if [[ -z "$(__rvm_18_compat_ruby)" ]]; then # TODO: install currently doesn't return the correct status. local compat_result=0 - if ! ( "$rvm_scripts_path/manage" install 1.8.7 ); then + if ! ( "$rvm_path/scripts/manage" install 1.8.7 ); then - "$rvm_scripts_path/log" "fail" \ + "$rvm_path/scripts/log" "fail" \ "To proceed rvm requires a 1.8-compatible ruby is installed. We attempted to install 1.8.7 automatically but it failed.\ Please install it manually (or a compatible alternative) to proceed." compat_result=1 @@ -394,50 +376,53 @@ } # Cleans up temp folders for a given prefix, # typically the current process id. __rvm_cleanup_temp_for() { + result=$? # Capture last command status - local prefix="$1" + local prefix + prefix="$1" + [[ -z "$prefix" ]] && return 1 if [[ -d "$rvm_tmp_path/" ]]; then \rm -rf "$rvm_tmp_path/$prefix"* >/dev/null 2>&1 fi - exit + return $result } __rvm_set_rvmrc() { if [[ "$HOME" != "$PWD" ]] ; then if [[ ${rvm_verbose_flag:-0} -gt 0 ]] ; then flags="use " ; fi if [[ -s .rvmrc ]] ; then mv .rvmrc .rvmrc.$(date +%m.%d.%Y-%H:%M:%S) - "$rvm_scripts_path/log" "warning" ".rvmrc is not empty, moving aside to preserve." + "$rvm_path/scripts/log" "warning" ".rvmrc is not empty, moving aside to preserve." fi local identifier=$(__rvm_environment_identifier) printf "if [[ -n \"\$rvm_environments_path\" && -s \"\$rvm_environments_path/$identifier\" ]] ; then\n \\. \"\$rvm_environments_path/$identifier\"" > .rvmrc printf "\nelse\n rvm --create $flags \"$identifier\"\nfi" >> .rvmrc unset flags else - "$rvm_scripts_path/log" "error" ".rvmrc cannot be set in your home directory. \n The home .rvmrc is for global rvm settings only." + "$rvm_path/scripts/log" "error" ".rvmrc cannot be set in your home directory. \n The home .rvmrc is for global rvm settings only." fi } __rvm_load_rvmrc() { rvm_ignore_rvmrc=${rvm_ignore_rvmrc:-0} [[ $rvm_ignore_rvmrc -eq 1 ]] && return 0 for rvmrc in /etc/rvmrc $HOME/.rvmrc ; do if [[ -f "$rvmrc" ]] ; then if \grep -q '^\s*rvm .*$' $rvmrc ; then - "$rvm_scripts_path/log" "error" "$rvmrc is for rvm settings only.\nrvm CLI may NOT be called from within $rvmrc. \nSkipping the loading of $rvmrc" + "$rvm_path/scripts/log" "error" "$rvmrc is for rvm settings only.\nrvm CLI may NOT be called from within $rvmrc. \nSkipping the loading of $rvmrc" return 1 else source "$rvmrc" fi fi @@ -460,11 +445,11 @@ # Override ruby string stuff, pass through. local old_rvm_ruby_string=$rvm_ruby_string # TODO: We can likely do this in a subshell in order to preserve the original environment? unset rvm_ruby_string export rvm_ruby_strings - "$rvm_scripts_path/set" "$rvm_action" $rvm_ruby_args + "$rvm_path/scripts/set" "$rvm_action" $rvm_ruby_args result=$? # Restore the state pre-sets. [[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string return $result @@ -483,11 +468,11 @@ } # Write the bin/ wrapper script for currently selected ruby. # TODO: Adjust binscript to be able to handle all rubies not just the standard interpreteres. __rvm_bin_script() { - "$rvm_scripts_path/wrapper" "$rvm_ruby_string" + "$rvm_path/scripts/wrapper" "$rvm_ruby_string" return $? } # Add bin path if not present __rvm_conditionally_add_bin_path() { @@ -519,40 +504,40 @@ # Go back to a clean state. __rvm_become "system" __rvm_unset_ruby_variables for system_config in system_ruby system_gem_path system_user_gem_path ; do - "$rvm_scripts_path/db" "$rvm_config_path/user" "$system_config" "delete" + "$rvm_path/scripts/db" "$rvm_config_path/user" "$system_config" "delete" done ; unset system_config variable \rm -f $rvm_bin_path/ruby $rvm_bin_path/gem $rvm_bin_path/rake $rvm_bin_path/irb $rvm_bin_path/default* return 0 } # Implode removes the entire rvm installation under $rvm_path. __rvm_implode() { while : ; do - "$rvm_scripts_path/log" "warn" "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')" + "$rvm_path/scripts/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 - "$rvm_scripts_path/log" "error" "remove '/' ?!... Ni!" + "$rvm_path/scripts/log" "error" "remove '/' ?!... Ni!" else if [[ -d "$rvm_path" ]] ; then - "$rvm_scripts_path/log" "info" "Hai! Removing $rvm_path" + "$rvm_path/scripts/log" "info" "Hai! Removing $rvm_path" \rm -rf "$rvm_path/" echo "$rvm_path has been removed." else - "$rvm_scripts_path/log" "info" "It appears that $rvm_path is already non existant." + "$rvm_path/scripts/log" "info" "It appears that $rvm_path is already non existant." fi fi break elif [[ "no" = "$response" ]] ; then - "$rvm_scripts_path/log" "info" "Cancelling implosion, no harm done :)" + "$rvm_path/scripts/log" "info" "Cancelling implosion, no harm done :)" break fi done return 0 @@ -561,11 +546,11 @@ # Output the current ruby's rvm source path. __rvm_source_dir() { if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi if [[ -z "$rvm_ruby_src_path" ]] ; then - "$rvm_scripts_path/log" "fail" "No source directory exists for the default implementation." + "$rvm_path/scripts/log" "fail" "No source directory exists for the default implementation." else echo "$rvm_ruby_src_path" fi return 0 @@ -594,11 +579,11 @@ fi [[ ${rvm_bin_flag:-0} -eq 1 ]] && __rvm_bin_scripts # Update to the latest rubygems. - [[ ${rvm_rubygems_flag:-0} -eq 1 ]] && "$rvm_scripts_path/rubygems" current + [[ ${rvm_rubygems_flag:-0} -eq 1 ]] && "$rvm_path/scripts/rubygems" current ) unset rvm_update_flag rvm_action rvm_self_flag rvm_ruby_revision rvm_bin_flag rvm_rubygems_flag return 0 } @@ -618,25 +603,25 @@ builtin cd "$rvm_src_path" && ( git clone --depth 1 git://github.com/wayneeseguin/rvm.git || git clone http://github.com/wayneeseguin/rvm.git ) && builtin cd rvm/ && ./scripts/install fi else stable_version="$(curl -s http://rvm.beginrescueend.com/releases/stable-version.txt)" - __rvm_run "fetch" "$rvm_scripts_path/fetch 'http://rvm.beginrescueend.com/releases/rvm-${stable_version}.tar.gz'" "fetching rvm-${stable_version}.tar.gz" + __rvm_run "fetch" "$rvm_path/scripts/fetch 'http://rvm.beginrescueend.com/releases/rvm-${stable_version}.tar.gz'" "fetching rvm-${stable_version}.tar.gz" __rvm_run "extract" "gunzip < \"$rvm_archives_path/rvm-${stable_version}.tar.gz\" | tar xf - -C $rvm_src_path" "Extracting rvm-${stable_version}.tar.gz ..." __rvm_run "install" "builtin cd $rvm_src_path/rvm-${stable_version}/ ; ./install" "Installing rvm-${stable_version}..." fi ) - rvm_hook="after_update" ; source "$rvm_scripts_path/hook" + rvm_hook="after_update" ; source "$rvm_path/scripts/hook" return 0 } __rvm_reboot() { - "$rvm_scripts_path/log" "warn" "Do you wish to reboot rvm? ('yes', or 'no')" + "$rvm_path/scripts/log" "warn" "Do you wish to reboot rvm? ('yes', or 'no')" local response="no" read response @@ -646,31 +631,31 @@ __rvm_reset mv "$rvm_path/archives" "$HOME/.archives" if [[ "/" = "$rvm_path" ]] ; then - "$rvm_scripts_path/log" "error" "remove '/' ?!... NO!" + "$rvm_path/scripts/log" "error" "remove '/' ?!... NO!" else if [[ -d "$rvm_path" ]] ; then \rm -rf "$rvm_path/" ; fi fi gem install rvm $rvm_gem_options __rvm_update_rvm source "$rvm_path/scripts/rvm" else - "$rvm_scripts_path/log" "info" "Carry on then..." + "$rvm_path/scripts/log" "info" "Carry on then..." fi return 0 } # Create the irbrc for the currently selected ruby installation. __rvm_irbrc() { if [[ -d "$rvm_ruby_home" && ! -s "$rvm_ruby_irbrc" ]] ; then - \cp "$rvm_scripts_path/irbrc" "$rvm_ruby_irbrc" + \cp "$rvm_path/scripts/irbrc" "$rvm_ruby_irbrc" fi return $? } # Save or restore the rvm's state. This is a toggle action. @@ -704,11 +689,11 @@ rvm_all_flag=${rvm_all_flag:-0} for binary in $rvm_ruby_args ; do actual_file="$(command -v $binary)" - "$rvm_scripts_path/log" "info" "$actual_file:" + "$rvm_path/scripts/log" "info" "$actual_file:" if [[ $rvm_shebang_flag -eq 1 ]] ; then \head -n 1 < "$actual_file" ; fi if [[ $rvm_env_flag -eq 1 ]] ; then \awk '/ENV/' < "$actual_file" ; fi if [[ $rvm_path_flag -eq 1 ]] ; then \awk '/PATH/' < "$actual_file" ; fi if [[ $rvm_head_flag -eq 1 ]] ; then \head -n 5 < "$actual_file" ; fi @@ -812,11 +797,11 @@ directory_name="$rvm_wrappers_path/$wrapper_identifier" if [[ ! -L "$directory_name" && ! -d "$directory_name" ]]; then \mkdir -p "$directory_name" - "$rvm_scripts_path/wrapper" "$wrapper_identifier" &> /dev/null + "$rvm_path/scripts/wrapper" "$wrapper_identifier" &> /dev/null fi rvm_creating_default_wrappers=0 done fi return 0 @@ -827,11 +812,11 @@ sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]\{1,\}/ /g' return $? } __rvm_using_gemset_globalcache() { - "$rvm_scripts_path/db" "$rvm_config_path/user" "use_gemset_globalcache" | \grep -q '^true$' + "$rvm_path/scripts/db" "$rvm_config_path/user" "use_gemset_globalcache" | \grep -q '^true$' return $? } __rvm_current_gemcache_dir() { if __rvm_using_gemset_globalcache; then @@ -894,31 +879,31 @@ return $? } __rvm_reset_rvmrc_trust() { touch "$rvm_config_path/rvmrcs" - "$rvm_scripts_path/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "delete" >/dev/null 2>&1 + "$rvm_path/scripts/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "delete" >/dev/null 2>&1 return $? } __rvm_trust_rvmrc() { touch "$rvm_config_path/rvmrcs" __rvm_reset_rvmrc_trust "$1" - "$rvm_scripts_path/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "1" >/dev/null 2>&1 + "$rvm_path/scripts/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "1" >/dev/null 2>&1 return $? } __rvm_untrust_rvmrc() { touch "$rvm_config_path/rvmrcs" __rvm_reset_rvmrc_trust "$1" - "$rvm_scripts_path/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "0" >/dev/null 2>&1 + "$rvm_path/scripts/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "0" >/dev/null 2>&1 return $? } __rvm_rvmrc_stored_trust() { touch "$rvm_config_path/rvmrcs" - "$rvm_scripts_path/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" + "$rvm_path/scripts/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" return $? } __rvm_rvmrc_tools() { local rvmrc_action="$1" @@ -1087,11 +1072,11 @@ local recorded_ruby_name rvm_install_record_file rvm_install_command [[ -z "$1" ]] && return - recorded_ruby_name="$($rvm_scripts_path/tools strings "$1")" + recorded_ruby_name="$($rvm_path/scripts/tools strings "$1")" rvm_install_record_file="$rvm_config_path/installs" rvm_install_command="$(echo "$recorded_ruby_name $rvm_install_arguments" | __rvm_strip)" @@ -1111,11 +1096,11 @@ } __rvm_remove_install_record() { local recorded_ruby_name rvm_install_record_file - recorded_ruby_name="$($rvm_scripts_path/tools strings "$1")" + recorded_ruby_name="$($rvm_path/scripts/tools strings "$1")" rvm_install_record_file="$rvm_config_path/installs" if [[ -s "$rvm_install_record_file" ]]; then @@ -1131,11 +1116,11 @@ __rvm_recorded_install_command() { local recorded_ruby_name recorded_ruby_match - recorded_ruby_name="$($rvm_scripts_path/tools strings "$1" | awk -F"$rvm_gemset_separator" '{print $1}')" + recorded_ruby_name="$($rvm_path/scripts/tools strings "$1" | awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')" [[ -z "$recorded_ruby_name" ]] && return 1 recorded_ruby_match="^$recorded_ruby_name " @@ -1166,23 +1151,23 @@ __rvm_expand_ruby_string() { local string="$1" if [[ -z "$string" || "$string" = "all" ]]; then - "$rvm_scripts_path/list" strings | tr ' ' "\n" + "$rvm_path/scripts/list" strings | tr ' ' "\n" elif [[ "$string" = "all-gemsets" ]]; then - "$rvm_scripts_path/list" gemsets strings + "$rvm_path/scripts/list" gemsets strings elif [[ "$string" = "default-with-rvmrc" || "$string" = "rvmrc" ]]; then - "$rvm_scripts_path/tools" path-identifier "$PWD" + "$rvm_path/scripts/tools" path-identifier "$PWD" elif [[ "$string" == "all-rubies" || "$string" = "rubies" ]]; then - "$rvm_scripts_path/list" rubies strings + "$rvm_path/scripts/list" rubies strings elif [[ "$string" == "current-ruby" || "$string" = "gemsets" ]]; then - local current_ruby="$(__rvm_environment_identifier | awk -F"$rvm_gemset_separator" '{print $string}')" - rvm_silence_logging=1 "$rvm_scripts_path/gemsets" list | sed "s/^/$current_ruby$rvm_gemset_separator/" + local current_ruby="$(__rvm_environment_identifier | awk -F"${rvm_gemset_separator:-"@"}" '{print $string}')" + rvm_silence_logging=1 "$rvm_path/scripts/gemsets" list | sed "s/^/$current_ruby${rvm_gemset_separator:-"@"}/" elif [[ "$string" = "current" ]]; then __rvm_environment_identifier elif [[ "$string" = "aliases" ]]; then