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.
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.
* reduce stale lock TTL to 2 min, check for stale lock before acquiring and each time -- to hold up new shell sessions for as little as possible
---------
Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
fixes stalling for 60s and failing if some past fault
has resulting in a stale lockfile being present
---------
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Skip sort, native extension probe, and per-symlink realpath
when called with --bare --skip-aliases (the rehash case).
Use readlink to distinguish internal aliases (relative target)
from external installs (absolute target).
In MacOS, speeds up rehash by 5.2 ms (7%) in empty environment,
55.9 ms (33%) in a regular environment (3 ver, 12 venvs, 320 bins),
93.7 ms (15%) in a large environment (6 ver, 60 venvs, 1466 bins)
register_shim() already deduplicates via associative array (bash 4+) or
by checking if a shim already exists (bash 3.2). The sort -u pipe in the make_shims
call is thus redundant -- the dedup happens downstream regardless. Shim
creation is order-independent and idempotent, so sorting has no semantic
effect either.
Saves one subprocess fork during every rehash invocation.
provides a reliable way for Pyenv code to locate other parts of Pyenv code that are not under `PYENV_ROOT`
* tests: Work with Git entirely in a test repo
Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>