File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 3333function verify_workon_home () {
3434 if [ ! -d "$WORKON_HOME" ]
3535 then
36- echo "ERROR: $WORKON_HOME does not exist! "
36+ echo "ERROR: Virtual environments directory ' $WORKON_HOME' does not exist. "
3737 return 1
3838 fi
3939 return 0
4040}
4141
42+ # Verify that the requested environment exists
43+ function verify_workon_environment () {
44+ typeset env_name="$1"
45+ if [ ! -d "$WORKON_HOME/$env_name" ]
46+ then
47+ echo "ERROR: Environment '$env_name' does not exist. Create it with 'mkvirtualenv $env_name'."
48+ return 1
49+ fi
50+ return 0
51+ }
52+
4253# Create a new environment, in the WORKON_HOME.
4354#
4455# Usage: mkvirtualenv [options] ENVNAME
@@ -57,7 +68,7 @@ function rmvirtualenv () {
5768 env_dir="$WORKON_HOME/$env_name"
5869 if [ "$VIRTUAL_ENV" == "$env_dir" ]
5970 then
60- echo "ERROR: You cannot remove the active environment."
71+ echo "ERROR: You cannot remove the active environment ('$env_name') ."
6172 return 1
6273 fi
6374 rm -rf "$env_dir"
@@ -81,10 +92,13 @@ function workon () {
8192 return 1
8293 fi
8394
95+ verify_workon_home || return 1
96+ verify_workon_environment $env_name || return 1
97+
8498 activate="$WORKON_HOME/$env_name/bin/activate"
8599 if [ ! -f "$activate" ]
86100 then
87- echo "ERROR: No activate for $WORKON_HOME/$env_name"
101+ echo "ERROR: Environment ' $WORKON_HOME/$env_name' does not contain an activate script. "
88102 return 1
89103 fi
90104
You can’t perform that action at this time.
0 commit comments