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 33
33
function verify_workon_home () {
34
34
if [ ! -d "$WORKON_HOME" ]
35
35
then
36
- echo "ERROR: $WORKON_HOME does not exist! "
36
+ echo "ERROR: Virtual environments directory ' $WORKON_HOME' does not exist. "
37
37
return 1
38
38
fi
39
39
return 0
40
40
}
41
41
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
+
42
53
# Create a new environment, in the WORKON_HOME.
43
54
#
44
55
# Usage: mkvirtualenv [options] ENVNAME
@@ -57,7 +68,7 @@ function rmvirtualenv () {
57
68
env_dir="$WORKON_HOME/$env_name"
58
69
if [ "$VIRTUAL_ENV" == "$env_dir" ]
59
70
then
60
- echo "ERROR: You cannot remove the active environment."
71
+ echo "ERROR: You cannot remove the active environment ('$env_name') ."
61
72
return 1
62
73
fi
63
74
rm -rf "$env_dir"
@@ -81,10 +92,13 @@ function workon () {
81
92
return 1
82
93
fi
83
94
95
+ verify_workon_home || return 1
96
+ verify_workon_environment $env_name || return 1
97
+
84
98
activate="$WORKON_HOME/$env_name/bin/activate"
85
99
if [ ! -f "$activate" ]
86
100
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. "
88
102
return 1
89
103
fi
90
104
You can’t perform that action at this time.
0 commit comments