瀏覽代碼

perf(sh-activate): avoid a duplicate pyenv-version-name call (#380)

pull/413/head
Ville Skyttä 2 年之前
committed by GitHub
父節點
當前提交
91609e25f3
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 1 個檔案被更改,包括 9 行新增6 行删除
  1. +9
    -6
      bin/pyenv-sh-activate

+ 9
- 6
bin/pyenv-sh-activate 查看文件

@ -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}"

Loading…
取消
儲存