mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-09 12:03: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
|
shift 1
|
||||||
done
|
done
|
||||||
|
|
||||||
|
get_current_versions() {
|
||||||
|
local IFS=:
|
||||||
|
current_versions=($(pyenv-version-name 2>/dev/null))
|
||||||
|
}
|
||||||
|
|
||||||
no_shell=
|
no_shell=
|
||||||
versions=("$@")
|
versions=("$@")
|
||||||
|
current_versions=()
|
||||||
if [ -z "${versions}" ]; then
|
if [ -z "${versions}" ]; then
|
||||||
no_shell=1
|
no_shell=1
|
||||||
OLDIFS="$IFS"
|
get_current_versions
|
||||||
IFS=: versions=($(pyenv-version-name 2>/dev/null))
|
versions=("${current_versions[@]}")
|
||||||
IFS="$OLDIFS"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${PYENV_VIRTUALENV_INIT}" ]; then
|
if [ -z "${PYENV_VIRTUALENV_INIT}" ]; then
|
||||||
@@ -84,9 +89,7 @@ fi
|
|||||||
|
|
||||||
if ! pyenv-virtualenv-prefix "${venv}" 1>/dev/null 2>&1; then
|
if ! pyenv-virtualenv-prefix "${venv}" 1>/dev/null 2>&1; then
|
||||||
# fallback to virtualenv of current version
|
# fallback to virtualenv of current version
|
||||||
OLDIFS="$IFS"
|
[ -n "${current_versions}" ] || get_current_versions
|
||||||
IFS=: current_versions=($(pyenv-version-name))
|
|
||||||
IFS="$OLDIFS"
|
|
||||||
new_venv="${current_versions%/envs/*}/envs/${venv}"
|
new_venv="${current_versions%/envs/*}/envs/${venv}"
|
||||||
if pyenv-virtualenv-prefix "${new_venv}" 1>/dev/null 2>&1; then
|
if pyenv-virtualenv-prefix "${new_venv}" 1>/dev/null 2>&1; then
|
||||||
venv="${new_venv}"
|
venv="${new_venv}"
|
||||||
|
|||||||
Reference in New Issue
Block a user