Skip to content

Commit 55ad84e

Browse files
committed
usability patches from Alex Satrapa
--HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401723
1 parent a06d5bb commit 55ad84e

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

virtualenvwrapper_bashrc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,23 @@ fi
3333
function 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

0 commit comments

Comments
 (0)