rehash: support BSD mktemp (#3376)

macOS 12 `mktemp' doesn't support `-p`
This commit is contained in:
native-api 2025-12-21 06:38:46 +03:00 committed by GitHub
parent aeea3ac825
commit a944da76c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -52,7 +52,7 @@ while (( SECONDS <= start + ${PYENV_REHASH_TIMEOUT:-60} )); do
#So check for writablity by trying to write to a different file,
# in a way that taxes the usual use case as little as possible.
if [[ -z $tested_for_other_write_errors ]]; then
( t="$(mktemp -p "$SHIM_PATH")" && rm "$t" ) && tested_for_other_write_errors=1 ||
( t="$(TMPDIR="$SHIM_PATH" mktemp)" && rm "$t" ) && tested_for_other_write_errors=1 ||
{ echo "pyenv: cannot rehash: $SHIM_PATH isnt writable" >&2; break; }
fi
# POSIX sleep(1) doesn't provide subsecond precision, but many others do