From 43b28caa9482badd990b6c7ef0fc37129f25904d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 9 Jun 2015 17:24:15 +0200 Subject: [PATCH] Fix discovering `.ruby-version` files in root directory It's not that this is a preferred way to set a global version (one should use `rbenv global ` instead), but this fixes the function purely for correctness: all parent directories should be scanned, even the root directory. Fixes #745 --- libexec/rbenv-version-file | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libexec/rbenv-version-file b/libexec/rbenv-version-file index 2413834f2b..7a2b9c6e0a 100755 --- a/libexec/rbenv-version-file +++ b/libexec/rbenv-version-file @@ -5,7 +5,7 @@ set -e find_local_version_file() { local root="$1" - while [ -n "$root" ]; do + while true; do if [ -e "${root}/.ruby-version" ]; then echo "${root}/.ruby-version" exit @@ -13,6 +13,7 @@ find_local_version_file() { echo "${root}/.rbenv-version" exit fi + [ -n "$root" ] || break root="${root%/*}" done }