scripts/cd in rvm-0.1.39 vs scripts/cd in rvm-0.1.40

- old
+ new

@@ -6,20 +6,32 @@ cd() { builtin cd "$@" local cwd ; cwd=$(pwd) while : ; do if [[ -z "$cwd" ]] || [[ "$HOME" = "$cwd" ]] || [[ "/" = "$cwd" ]] ; then - if [[ "$rvm_project_rvmrc_default" -eq 1 ]] ; then - rvm default 1>/dev/null 2>&1 + if [[ ! -z "$rvm_rvmrc_cwd" ]] ; then + if [[ -z "$rvm_previous_environment" ]] ; then + rvm default 1>/dev/null 2>&1 + else + rvm "$rvm_previous_environment" 1>/dev/null 2>&1 + fi + unset rvm_rvmrc_cwd rvm_previous_environment fi break else if [[ -f "$cwd/.rvmrc" ]] ; then - source "$cwd/.rvmrc" + if [[ "$rvm_rvmrc_cwd" != "$cwd" ]] ; then + if [[ -z "$rvm_previous_environment" ]] ; then + rvm_previous_environment="$(__rvm_environment_identifier)" + fi + rvm_rvmrc_cwd="$cwd" + source "$cwd/.rvmrc" + fi break else cwd=$(dirname "$cwd") fi fi done + } fi