virtualenvwrapper / virtualenvwrapper_bashrc

Diff from to

virtualenvwrapper_bashrc

 function verify_workon_home () {
     if [ ! -d "$WORKON_HOME" ]
     then
-        echo "ERROR: $WORKON_HOME does not exist!"
+        echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist."
         return 1
     fi
     return 0
 }
 
+# Verify that the requested environment exists
+function verify_workon_environment () {
+       typeset env_name="$1"
+       if [ ! -d "$WORKON_HOME/$env_name" ]
+    then
+       echo "ERROR: Environment '$env_name' does not exist. Create it with 'mkvirtualenv $env_name'."
+       return 1
+    fi
+    return 0
+}
+
 # Create a new environment, in the WORKON_HOME.
 #
 # Usage: mkvirtualenv [options] ENVNAME
     env_dir="$WORKON_HOME/$env_name"
     if [ "$VIRTUAL_ENV" == "$env_dir" ]
     then
-        echo "ERROR: You cannot remove the active environment."
+        echo "ERROR: You cannot remove the active environment ('$env_name')."
         return 1
     fi
     rm -rf "$env_dir"
         return 1
     fi
 
+    verify_workon_home || return 1
+    verify_workon_environment $env_name || return 1
+    
     activate="$WORKON_HOME/$env_name/bin/activate"
     if [ ! -f "$activate" ]
     then
-        echo "ERROR: No activate for $WORKON_HOME/$env_name"
+        echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script."
         return 1
     fi
     
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.