Files
pyenv/libexec/pyenv-version-origin
Saloni GuptaandIvan Pozdeev 7c877e06a0 Harden source scripts with set -euo pipefail and set -f (#3581)
Only use -f whenever there's an unquoted word split where globbing is undesired

---------

Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
2026-10-13 20:20:36 +03:00

26 lines
643 B
Bash
Executable File

#!/usr/bin/env bash
# Summary: Explain how the current Python version is set
set -euo pipefail
[ -n "${PYENV_DEBUG:-}" ] && set -x
PYENV_VERSION_ORIGIN=
OLDIFS="$IFS"
IFS=$'\n' scripts=(`pyenv-hooks version-origin`)
IFS="$OLDIFS"
# bash < 4.4 (incl. macOS's 3.2) treats an empty array as unbound under set -u,
# and hooks are third-party code, so relax nounset while sourcing them
set +u
for script in "${scripts[@]}"; do
source "$script"
done
set -u
if [[ -n ${PYENV_VERSION_ORIGIN:-} ]]; then
echo "$PYENV_VERSION_ORIGIN"
elif [[ -n ${PYENV_VERSION:-} ]]; then
echo "PYENV_VERSION environment variable"
else
pyenv-version-file
fi