Skip to content

activate.sh: handle empty (but set) vars #723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions virtualenv_embedded/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ deactivate () {
unset pydoc

# reset old environment variables
if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
if ! [ -z "${_OLD_VIRTUAL_PATH+x}" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then
if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+x}" ] ; then
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
Expand All @@ -23,7 +23,7 @@ deactivate () {
hash -r 2>/dev/null
fi

if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
if ! [ -z "${_OLD_VIRTUAL_PS1+x}" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
Expand All @@ -46,10 +46,8 @@ _OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/__BIN_NAME__:$PATH"
export PATH

# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "$PYTHONHOME" ] ; then
# Unset PYTHONHOME if set.
if ! [ -z ${PYTHONHOME+x} ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi
Expand Down