mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-08 11:33:55 -05:00
perf(sh-activate): avoid a duplicate pyenv-version-name call (#380)
This commit is contained in:
@@ -52,13 +52,18 @@ while [ $# -gt 0 ]; do
|
||||
shift 1
|
||||
done
|
||||
|
||||
get_current_versions() {
|
||||
local IFS=:
|
||||
current_versions=($(pyenv-version-name 2>/dev/null))
|
||||
}
|
||||
|
||||
no_shell=
|
||||
versions=("$@")
|
||||
current_versions=()
|
||||
if [ -z "${versions}" ]; then
|
||||
no_shell=1
|
||||
OLDIFS="$IFS"
|
||||
IFS=: versions=($(pyenv-version-name 2>/dev/null))
|
||||
IFS="$OLDIFS"
|
||||
get_current_versions
|
||||
versions=("${current_versions[@]}")
|
||||
fi
|
||||
|
||||
if [ -z "${PYENV_VIRTUALENV_INIT}" ]; then
|
||||
@@ -84,9 +89,7 @@ fi
|
||||
|
||||
if ! pyenv-virtualenv-prefix "${venv}" 1>/dev/null 2>&1; then
|
||||
# fallback to virtualenv of current version
|
||||
OLDIFS="$IFS"
|
||||
IFS=: current_versions=($(pyenv-version-name))
|
||||
IFS="$OLDIFS"
|
||||
[ -n "${current_versions}" ] || get_current_versions
|
||||
new_venv="${current_versions%/envs/*}/envs/${venv}"
|
||||
if pyenv-virtualenv-prefix "${new_venv}" 1>/dev/null 2>&1; then
|
||||
venv="${new_venv}"
|
||||
|
||||
Reference in New Issue
Block a user