1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-22 12:48:01 +00:00

Add check for empty WORKON_HOME (#1861)

When $WORKON_HOME is not set and $ENV_NAME is equal to
$PROJECT_ROOT/.venv which contains bin/activate then
the code wrongly assumes workon is available.

It should execute the second branch to source bin/activate.
This commit is contained in:
Olaf Conradi 2020-07-27 21:49:40 +02:00 committed by GitHub
parent 685da200d7
commit e9197234cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,7 +71,7 @@ function _python-workon-cwd {
if [[ "$ENV_NAME" != "" ]]; then if [[ "$ENV_NAME" != "" ]]; then
# Activate the environment only if it is not already active # Activate the environment only if it is not already active
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then if [[ -n "$WORKON_HOME" && -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
elif [[ -e "$ENV_NAME/bin/activate" ]]; then elif [[ -e "$ENV_NAME/bin/activate" ]]; then
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"