mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-14 14:23:53 -05:00
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.
This commit is contained in:
@@ -4,8 +4,8 @@ set -e
|
|||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
find_local_version_file() {
|
find_local_version_file() {
|
||||||
local root="$1"
|
local prev root="$1"
|
||||||
while [ -n "$root" ]; do
|
while [ -n "$root" ] && [ "$root" != "$prev" ]; do
|
||||||
if [ -e "${root}/.python-version" ]; then
|
if [ -e "${root}/.python-version" ]; then
|
||||||
echo "${root}/.python-version"
|
echo "${root}/.python-version"
|
||||||
exit
|
exit
|
||||||
@@ -13,6 +13,7 @@ find_local_version_file() {
|
|||||||
echo "${root}/.pyenv-version"
|
echo "${root}/.pyenv-version"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
prev="${root}"
|
||||||
root="${root%/*}"
|
root="${root%/*}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user