Skip to content

Commit a97ad3b

Browse files
committed
check return code from virtualenvwrapper_verify_workon_home everywhere and return an error code if validation fails
1 parent 6924e8e commit a97ad3b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

test.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,23 @@ deactivate
4545

4646
echo
4747
echo "LISTING ENVIRONMENTS"
48-
workon
48+
envs=`workon | tr '\n' ' '`
49+
if [ "$envs" = "env1 env2 " ]
50+
then
51+
echo "PASS"
52+
else
53+
echo "FAIL: \""$envs\"""
54+
fi
4955

5056
echo
5157
echo "REMOVING ENVIRONMENTS"
5258
rmvirtualenv "env1"
5359
rmvirtualenv "env2"
5460

5561
rm -rf $WORKON_HOME
62+
63+
echo
64+
echo "MISSING WORKON_HOME"
65+
workon && echo "Failed to detect missing dir" || echo "PASS"
66+
mkvirtualenv foo && echo "Failed to detect missing dir" || echo "PASS"
67+
rmvirtualenv foo && echo "Failed to detect missing dir" || echo "PASS"

virtualenvwrapper_bashrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function virtualenvwrapper_run_hook () {
8282
#
8383
function mkvirtualenv () {
8484
eval "envname=\$$#"
85-
virtualenvwrapper_verify_workon_home
85+
virtualenvwrapper_verify_workon_home || return 1
8686
(cd "$WORKON_HOME";
8787
virtualenv "$@";
8888
virtualenvwrapper_run_hook "./premkvirtualenv" "$envname"
@@ -94,7 +94,7 @@ function mkvirtualenv () {
9494
# Remove an environment, in the WORKON_HOME.
9595
function rmvirtualenv () {
9696
typeset env_name="$1"
97-
virtualenvwrapper_verify_workon_home
97+
virtualenvwrapper_verify_workon_home || return 1
9898
if [ "$env_name" = "" ]
9999
then
100100
echo "Please specify an enviroment."
@@ -114,7 +114,7 @@ function rmvirtualenv () {
114114

115115
# List the available environments.
116116
function virtualenvwrapper_show_workon_options () {
117-
virtualenvwrapper_verify_workon_home
117+
virtualenvwrapper_verify_workon_home || return 1
118118
find "$WORKON_HOME" -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \; | sort
119119
}
120120

0 commit comments

Comments
 (0)