Fall back to $PWD if a local version file can't be found in $RBENV_DIR

This commit is contained in:
Sam Stephenson 2012-12-27 13:39:36 -06:00
parent c3fe192243
commit 6c1fb9ffd0

View file

@ -2,14 +2,19 @@
set -e set -e
[ -n "$RBENV_DEBUG" ] && set -x [ -n "$RBENV_DEBUG" ] && set -x
root="$RBENV_DIR" find_local_version_file() {
while [ -n "$root" ]; do local root="$1"
if [ -e "${root}/.rbenv-version" ]; then while [ -n "$root" ]; do
echo "${root}/.rbenv-version" if [ -e "${root}/.rbenv-version" ]; then
exit echo "${root}/.rbenv-version"
fi exit
root="${root%/*}" fi
done root="${root%/*}"
done
}
find_local_version_file "$RBENV_DIR"
[ "$RBENV_DIR" = "$PWD" ] || find_local_version_file "$PWD"
global_version_file="${RBENV_ROOT}/version" global_version_file="${RBENV_ROOT}/version"