From ddaeb0c27e6eb41c77c1ccdf4db78e3eb69d1220 Mon Sep 17 00:00:00 2001 From: Jarek 'jarekps' Smiejczak Date: Wed, 11 Sep 2013 19:27:32 +0200 Subject: [PATCH] Resets PYTHONPATH even when was unset (#56) --- linux/templates/bin/activate | 8 +++++--- mac/templates/bin/activate | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/linux/templates/bin/activate b/linux/templates/bin/activate index fd79aa6..178a6e7 100644 --- a/linux/templates/bin/activate +++ b/linux/templates/bin/activate @@ -3,7 +3,9 @@ # Inject command to deactivate the environment deactivate () { - if [ -n "$_OLD_PATH" ] ; then + # Reset PATH, PS1 and PYTHONPATH to their previous state + # from before activation + if [ "$_OLD_PATH" == "${_OLD_PATH-unset}" ] ; then PATH="$_OLD_PATH" export PATH unset _OLD_PATH @@ -16,13 +18,13 @@ deactivate () { hash -r fi - if [ -n "$_OLD_PS1" ] ; then + if [ "$_OLD_PS1" == "${_OLD_PS1-unset}" ] ; then PS1="$_OLD_PS1" export PS1 unset _OLD_PS1 fi - if [ -n "$_OLD_PYTHONPATH" ] ; then + if [ "$_OLD_PYTHONPATH" == "${_OLD_PYTHONPATH-unset}" ] ; then PYTHONPATH="$_OLD_PYTHONPATH" export PYTHONPATH unset _OLD_PYTHONPATH diff --git a/mac/templates/bin/activate b/mac/templates/bin/activate index fd79aa6..178a6e7 100644 --- a/mac/templates/bin/activate +++ b/mac/templates/bin/activate @@ -3,7 +3,9 @@ # Inject command to deactivate the environment deactivate () { - if [ -n "$_OLD_PATH" ] ; then + # Reset PATH, PS1 and PYTHONPATH to their previous state + # from before activation + if [ "$_OLD_PATH" == "${_OLD_PATH-unset}" ] ; then PATH="$_OLD_PATH" export PATH unset _OLD_PATH @@ -16,13 +18,13 @@ deactivate () { hash -r fi - if [ -n "$_OLD_PS1" ] ; then + if [ "$_OLD_PS1" == "${_OLD_PS1-unset}" ] ; then PS1="$_OLD_PS1" export PS1 unset _OLD_PS1 fi - if [ -n "$_OLD_PYTHONPATH" ] ; then + if [ "$_OLD_PYTHONPATH" == "${_OLD_PYTHONPATH-unset}" ] ; then PYTHONPATH="$_OLD_PYTHONPATH" export PYTHONPATH unset _OLD_PYTHONPATH