1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-10 12:33:48 -05:00

Auto-resolve prefixes to the latest version (#2487)

This commit is contained in:
native-api
2022-10-30 03:38:40 +03:00
committed by GitHub
parent 0b5e16add3
commit a12f947cc3
13 changed files with 258 additions and 13 deletions

View File

@@ -139,3 +139,29 @@ assert_output_contains() {
} | flunk
}
}
# Output a modified PATH that ensures that the given executable is not present,
# but in which system utils necessary for pyenv operation are still available.
path_without() {
local path=":${PATH}:"
for exe; do
local found alt util
for found in $(PATH="$path" type -aP "$exe"); do
found="${found%/*}"
if [ "$found" != "${PYENV_ROOT}/shims" ]; then
alt="${PYENV_TEST_DIR}/$(echo "${found#/}" | tr '/' '-')"
mkdir -p "$alt"
for util in bash head cut readlink greadlink; do
if [ -x "${found}/$util" ]; then
ln -s "${found}/$util" "${alt}/$util"
fi
done
path="${path/:${found}:/:${alt}:}"
fi
done
done
path="${path#:}"
path="${path%:}"
echo "$path"
}