save-ebuild-env.sh: tweak PYTHONPATH cleansing
authorZac Medico <zmedico@gentoo.org>
Mon, 12 Sep 2011 03:06:27 +0000 (20:06 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 12 Sep 2011 03:06:27 +0000 (20:06 -0700)
bin/save-ebuild-env.sh

index 3bb8255ab3145f97270e340174c67f3c6610fb98..a84a1258b40e70112f5ccb228604de97c2dda896 100644 (file)
@@ -14,9 +14,13 @@ save_ebuild_env() {
        (
        if has --exclude-init-phases $* ; then
                unset S _E_DOCDESTTREE_ _E_EXEDESTTREE_
-               if [[ -n $PYTHONPATH ]] ; then
-                       export PYTHONPATH=${PYTHONPATH/${PORTAGE_PYM_PATH}:}
-                       [[ -z $PYTHONPATH ]] && unset PYTHONPATH
+               if [[ -n $PYTHONPATH &&
+                       ${PYTHONPATH%%:*} -ef $PORTAGE_PYM_PATH ]] ; then
+                       if [[ $PYTHONPATH == *:* ]] ; then
+                               export PYTHONPATH=${PYTHONPATH#*:}
+                       else
+                               unset PYTHONPATH
+                       fi
                fi
        fi