Skip to content
This repository

Improve interaction with -u #357

Open
wants to merge 1 commit into from

2 participants

Danny Staple Pat Pannuto
Danny Staple

Currently if activate is sourced from within a script that uses "set -u" to detect unset variables, it will fail as shown in #150.
This proposed change should fix it.

Danny Staple Improve interaction with -u
Currently if activate is sourced from within a script that uses "set -u" to detect unset variables, it will fail as shown in pypa#150.
This proposed change should fix it.
a220ed9
Pat Pannuto

@pypa Is there a reason this was never pulled? This is still a problem... just got bitten by this today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 21, 2012
Danny Staple Improve interaction with -u
Currently if activate is sourced from within a script that uses "set -u" to detect unset variables, it will fail as shown in pypa#150.
This proposed change should fix it.
a220ed9
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 19 additions and 1 deletion. Show diff stats Hide diff stats

  1. 20  virtualenv_embedded/activate.sh
20  virtualenv_embedded/activate.sh
@@ -3,7 +3,10 @@
3 3
 
4 4
 deactivate () {
5 5
     unset pydoc
6  
-
  6
+    if [[ $- =~ 'u' ]] ; then
  7
+        UNSET_OPTION=1
  8
+        set +u
  9
+    fi
7 10
     # reset old environment variables
8 11
     if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
9 12
         PATH="$_OLD_VIRTUAL_PATH"
@@ -34,8 +37,18 @@ deactivate () {
34 37
     # Self destruct!
35 38
         unset -f deactivate
36 39
     fi
  40
+    
  41
+    if [ -n $UNSET_OPTION ] ; then 
  42
+        set -u
  43
+        unset UNSET_OPTION
  44
+    fi
37 45
 }
38 46
 
  47
+if [[ $- =~ 'u' ]] ; then
  48
+    UNSET_OPTION=1
  49
+    set +u
  50
+fi
  51
+
39 52
 # unset irrelevant variables
40 53
 deactivate nondestructive
41 54
 
@@ -78,3 +91,8 @@ alias pydoc="python -m pydoc"
78 91
 if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
79 92
     hash -r 2>/dev/null
80 93
 fi
  94
+
  95
+if [ -n $UNSET_OPTION ] ; then 
  96
+    set -u
  97
+    unset UNSET_OPTION
  98
+fi
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.