From 8dc4e8d6f87bcddf276b1fb64e70200c32c22c75 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Fri, 3 Jan 2014 07:39:52 +0900 Subject: [PATCH 1/2] Revert "Merge branch 'golang-workaround'" This reverts commit 7edceff71ca6aa1281658f6f60ca2e48a6e3f45f, reversing changes made to 5dea3c9e63e49b69284822f8f529778e6b55adf0. --- libexec/pyenv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/pyenv b/libexec/pyenv index 65e80d22..05955aa7 100755 --- a/libexec/pyenv +++ b/libexec/pyenv @@ -44,13 +44,13 @@ fi export PYENV_ROOT if [ -z "${PYENV_DIR}" ]; then - PYENV_DIR="$(abs_dirname "$(pwd)/..")" + PYENV_DIR="$(pwd)" else cd "$PYENV_DIR" 2>/dev/null || { echo "pyenv: cannot change working directory to \`$PYENV_DIR'" exit 1 } >&2 - PYENV_DIR="$(abs_dirname "$(pwd)/..")" + PYENV_DIR="$(pwd)" cd "$OLDPWD" fi export PYENV_DIR From 4c5ffc8d993160e72625d0c054c956c07fe5870a Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Fri, 3 Jan 2014 07:43:39 +0900 Subject: [PATCH 2/2] Avoid infinite loop in case where `pwd` returns relative path The `pwd` may return relative path if the `$PWD` is badly declared in bash/zsh (e.g. `PWD="." bash`). To avoid the infinite loop in `find_local_version_file()`, stop finding the version file if the target paths are same consecutively. --- libexec/pyenv-version-file | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libexec/pyenv-version-file b/libexec/pyenv-version-file index d4c563f9..b6b2fa35 100755 --- a/libexec/pyenv-version-file +++ b/libexec/pyenv-version-file @@ -4,8 +4,8 @@ set -e [ -n "$PYENV_DEBUG" ] && set -x find_local_version_file() { - local root="$1" - while [ -n "$root" ]; do + local prev root="$1" + while [ -n "$root" ] && [ "$root" != "$prev" ]; do if [ -e "${root}/.python-version" ]; then echo "${root}/.python-version" exit @@ -13,6 +13,7 @@ find_local_version_file() { echo "${root}/.pyenv-version" exit fi + prev="${root}" root="${root%/*}" done }