scripts/utility in rvm-0.0.84 vs scripts/utility in rvm-0.0.85

- old
+ new

@@ -1,7 +1,26 @@ #!/usr/bin/env bash +__rvm_db() { + key=$1 ; variable=$2 + if [[ -f "$rvm_config_path/user" ]] ; then + value="$($rvm_scripts_path/db "$rvm_config_path/user" "$key")" + fi + + if [[ -z "$value" ]] ; then + value="$($rvm_scripts_path/db "$rvm_config_path/db" "$key")" + fi + + if [[ ! -z "$value" ]] ; then + if [[ -z $variable ]] ; then + echo $value + else + eval "$variable=$value" + fi + fi +} + __rvm_info() { if [[ ! -z "$(which ruby 2>/dev/null)" ]] ; then full_version=$(ruby -v) ; fi cat <<Info @@ -164,29 +183,29 @@ echo "${variable}='$value' ; export ${variable}" >> $rvm_path/system fi done fi - rvm_system_ruby=$($rvm_scripts_path/db "$rvm_config_path/db" "system_ruby") + __rvm_db "system_ruby" "rvm_system_ruby" if [[ ! -z "$rvm_system_ruby" ]] ; then rvm_system_ruby=$(which ruby 2>/dev/null) if [[ $? -ne 0 ]] ; then $rvm_scripts_path/log "info" "System ruby not found, no system default will be stored." else - $rvm_scripts_path/db "$rvm_config_path/db" "system_ruby" "$rvm_system_ruby" + $rvm_scripts_path/db "$rvm_config_path/user" "system_ruby" "$rvm_system_ruby" # Now store system system & user gem paths if [[ ! -z "$(which gem 2>/dev/null)" ]] ; then - rvm_system_user_gem_path=$($rvm_scripts_path/db "$rvm_config_path/db" "system_user_gem_path") + __rvm_db "system_user_gem_path" "rvm_system_user_gem_path" if [[ -z "$rvm_system_user_gem_path" ]] ; then rvm_system_user_gem_path=$( rvm system ; gem env gemdir user; ) - $rvm_scripts_path/db "$rvm_config_path/db" "system_user_gem_path" "$rvm_system_user_gem_path" + $rvm_scripts_path/db "$rvm_config_path/user" "system_user_gem_path" "$rvm_system_user_gem_path" fi - rvm_system_gem_path=$($rvm_scripts_path/db "$rvm_config_path/db" "system_gem_path") + __rvm_db "system_gem_path" "rvm_system_gem_path" if [[ -z "$rvm_system_gem_path" ]] ; then rvm_system_gem_path=$( rvm system ; gem env gemdir; ) - $rvm_scripts_path/db "$rvm_config_path/db" "system_gem_path" "$rvm_system_gem_path" + $rvm_scripts_path/db "$rvm_config_path/user" "system_gem_path" "$rvm_system_gem_path" fi fi fi fi } @@ -202,11 +221,11 @@ done rvm_ruby_interpreter="system" __rvm_select for system_config in system_ruby system_gem_path system_user_gem_path ; do - $rvm_scripts_path/db "$rvm_config_path/db" "$system_config" "delete" + $rvm_scripts_path/db "$rvm_config_path/user" "$system_config" "delete" 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* } @@ -342,20 +361,23 @@ 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 ; which ruby 2>/dev/null && ruby -v 2> /dev/null) - if [[ ! -z "$system_version" ]] ; then - if [[ "$($(which ruby) -v)" = "$system_version" ]] ; then + system_ruby="$(rvm system ; which ruby 2>/dev/null)" + if [[ ! -z "$system_ruby" ]] ; then + system_version=$($system_ruby -v) + if [[ ! -z "$(which ruby 2>/dev/null)" ]] && [[ "$($(which ruby 2>/dev/null) -v)" = "$system_version" ]] ; then echo -e "=> $(tput setaf 2)system$(tput sgr0) ( ruby -v # => $system_version )\n" else echo -e " $(tput setaf 2)system$(tput sgr0) ( ruby -v # => $system_version )\n" fi else $rvm_scripts_path/log "info" "No system ruby found." - fi ; unset current_ruby version selected + fi + + unset current_ruby version selected system_ruby system_version string fi } __rvm_initialize() { rvm_ruby_load_path="." @@ -366,11 +388,11 @@ rvm_result=$(echo $PATH | grep 'rvm\/bin:') if [[ -z "$rvm_result" ]] ; then PATH=$rvm_bin_path:$PATH ; export PATH fi - mkdir -p $rvm_src_path $rvm_bin_path $rvm_archives_path $rvm_gem_path $rvm_temp_path + mkdir -p $rvm_src_path $rvm_bin_path $rvm_archives_path $rvm_gem_path $rvm_tmp_path } __rvm_update() { if [[ "head" = "$rvm_ruby_revision" ]] || [[ ! -z "$rvm_self_flag" ]] || [[ "update" = "$rvm_action" ]] || [[ ! -z "$rvm_update_flag" ]] ; then __rvm_version @@ -568,17 +590,17 @@ return ${#errors[*]} } __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" + echo -e "$code" > "$rvm_tmp_path/$$.rb" unset code - cat $rvm_ruby_file >> "$rvm_temp_path/$$.rb" - echo -e "\n end \nend\n" >> "$rvm_temp_path/$$.rb" - rvm_ruby_args="$rvm_temp_path/$$.rb" + cat $rvm_ruby_file >> "$rvm_tmp_path/$$.rb" + echo -e "\n end \nend\n" >> "$rvm_tmp_path/$$.rb" + rvm_ruby_args="$rvm_tmp_path/$$.rb" rvm_benchmark_flag=1 rvm_action="ruby" - if [[ ! -z "$rvm_debug_flag" ]] ; then echo -e "$rvm_temp_path/$$.rb:\n$(cat $rvm_temp_path/$$.rb)" ; fi + if [[ ! -z "$rvm_debug_flag" ]] ; then echo -e "$rvm_tmp_path/$$.rb:\n$(cat $rvm_tmp_path/$$.rb)" ; fi __rvm_do } __rvm_irbrc() { # Create the irbrc for the currently selected ruby installation.