This commit is contained in:
Tim Hawes 2026-09-09 04:44:24 -07:00 committed by GitHub
commit a3d3c086a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -42,9 +42,13 @@ versions_dir="${PYENV_ROOT}/versions"
if [[ -n "$executables" ]]; then
if [ -d "$versions_dir" ]; then
shopt -s dotglob nullglob
# MacOS 12+ and FreeBSD 15 support `xargs -r -0' and `basename -a'
# `sort -u` is simpler and a bit faster than `awk '!seen[$0]++'`, with the same result for rehash purposes
printf '%s\0' "$versions_dir"/*/bin/* "$versions_dir"/*/envs/*/bin/* | xargs -0 -r basename -a | sort -u
# Fast path for rehash: skip filtering and link resolution.
# Discover executables directly from the versions directory and
# deduplicate their basenames. Use bash 3.2 conventions to keep code portable.
paths=( "$versions_dir"/*/bin/* "$versions_dir"/*/envs/*/bin/* )
if [ "${#paths[@]}" -gt 0 ]; then
printf '%s\n' "${paths[@]##*/}" | sort -u
fi
shopt -u dotglob nullglob
fi
exit 0