mirror of
https://github.com/pyenv/pyenv.git
synced 2026-09-10 07:36:16 -04:00
versions: fix --executables portability regression
Replace the use of `xargs -r` and `basename -a` in the `--executables` fast path with Bash 3.2-compatible parameter expansion. The previous implementation relied on non-portable utility options, causing `pyenv rehash` and shell initialization to fail on illumos, OpenBSD, and other non-GNU userlands. Preserve the optimized executable discovery path by continuing to discover executables directly from the versions directory and deduplicate their basenames.
This commit is contained in:
parent
bdf8d254fe
commit
a33b30fa2d
|
|
@ -42,9 +42,15 @@ 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.
|
||||
for path in \
|
||||
"$versions_dir"/*/bin/* \
|
||||
"$versions_dir"/*/envs/*/bin/*
|
||||
do
|
||||
printf '%s\n' "${path##*/}"
|
||||
done | sort -u
|
||||
shopt -u dotglob nullglob
|
||||
fi
|
||||
exit 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue