mirror of
https://github.com/pyenv/pyenv.git
synced 2026-10-04 00:11:06 +09:00
Only test for UNC paths every iteration if they are special
This commit is contained in:
parent
195b9fe940
commit
48e70e1fe9
@ -11,12 +11,24 @@ find_local_version_file() {
|
|||||||
# Nonexistent paths are UB as of this writing.
|
# Nonexistent paths are UB as of this writing.
|
||||||
# Relative ones cause a failure but absolute ones don't
|
# Relative ones cause a failure but absolute ones don't
|
||||||
[[ $root != /* ]] && root=$(CDPATH= cd -- "$root" && pwd)
|
[[ $root != /* ]] && root=$(CDPATH= cd -- "$root" && pwd)
|
||||||
while ! [[ "$root" =~ ^//[^/]*$ ]]; do
|
# Original Rbenv code supports UNC notaion for Cygwin/MinGW
|
||||||
if [ -f "${root}/.python-version" ]; then
|
# (https://github.com/rbenv/rbenv/pull/529)
|
||||||
echo "${root}/.python-version"
|
# POSIX.1-2024 still allows to treat //<name> in implementation-specific manner
|
||||||
|
# (https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap04.html#tag_04_16)
|
||||||
|
# even though few UNIX variants do that
|
||||||
|
local unc; [[ $root =~ ^//[^/] && ! / -ef // ]] && unc=1
|
||||||
|
# when testing root, $root is ""
|
||||||
|
while true; do
|
||||||
|
# don't test //.python-version if // is special
|
||||||
|
# as it's pointless and possibly very slow
|
||||||
|
# if it e.g. leads to a network search
|
||||||
|
[[ $unc && $root == / ]] && break
|
||||||
|
|
||||||
|
if [[ -f $root/.python-version ]]; then
|
||||||
|
echo "$root/.python-version"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
[ -n "$root" ] || break
|
[[ -n $root ]] || break
|
||||||
root="${root%/*}"
|
root="${root%/*}"
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user