From 6c1fb9ffd062ff04607d2e0f486067eaf6e48d1e Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Thu, 27 Dec 2012 13:39:36 -0600 Subject: [PATCH] Fall back to $PWD if a local version file can't be found in $RBENV_DIR --- libexec/rbenv-version-file | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libexec/rbenv-version-file b/libexec/rbenv-version-file index 9b678769..e9451f42 100755 --- a/libexec/rbenv-version-file +++ b/libexec/rbenv-version-file @@ -2,14 +2,19 @@ set -e [ -n "$RBENV_DEBUG" ] && set -x -root="$RBENV_DIR" -while [ -n "$root" ]; do - if [ -e "${root}/.rbenv-version" ]; then - echo "${root}/.rbenv-version" - exit - fi - root="${root%/*}" -done +find_local_version_file() { + local root="$1" + while [ -n "$root" ]; do + if [ -e "${root}/.rbenv-version" ]; then + echo "${root}/.rbenv-version" + exit + fi + root="${root%/*}" + done +} + +find_local_version_file "$RBENV_DIR" +[ "$RBENV_DIR" = "$PWD" ] || find_local_version_file "$PWD" global_version_file="${RBENV_ROOT}/version"