versions: fix portability regression in --executables

Commit 8037f226 introduced the `--executables` fast path using
`xargs -r` and `basename -a`. Those options are unavailable on
illumos and OpenBSD, breaking `pyenv rehash` on those platforms.

Replace the GNU-specific invocation with a Bash 3.2-compatible
implementation while preserving the direct executable discovery
optimization.
This commit is contained in:
Tim Hawes 2026-08-03 20:55:42 -04:00
parent a33b30fa2d
commit bb07d2e18a
No known key found for this signature in database
GPG key ID: 7927112CC0EB3597

View file

@ -45,12 +45,10 @@ if [[ -n "$executables" ]]; then
# 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
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