Skip to content

Commit 3eb6ba8

Browse files
committed
fix lazy-loader function definitions under zsh; fixes #144
1 parent 58eae98 commit 3eb6ba8

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

docs/en/history.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dev
77
- Switch to stevedore_ for plugin management
88
- mkvirtualenv_help should use ``$VIRTUALENVWRAPPER_PYTHON`` instead
99
of calling ``virtualenv`` directly (:bbissue:`148`).
10+
- Fix issue with lazy-loader code under zsh (:bbissue:`144`).
1011

1112
.. _stevedore: http://pypi.python.org/pypi/stevedore
1213

tests/test_lazy.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
#!/bin/sh
21

32
test_dir=$(cd $(dirname $0) && pwd)
43
source "$test_dir/setup.sh"
54

65
oneTimeSetUp() {
76
rm -rf "$WORKON_HOME"
87
mkdir -p "$WORKON_HOME"
8+
[ ! -z "$ZSH_VERSION" ] && unsetopt shwordsplit
99
source "$test_dir/../virtualenvwrapper_lazy.sh"
10+
[ ! -z "$ZSH_VERSION" ] && setopt shwordsplit
1011
}
1112

1213
oneTimeTearDown() {
@@ -22,6 +23,13 @@ function_defined_lazy() {
2223
name="$1"
2324
assertTrue "$name not defined" "type $name"
2425
assertTrue "$name does not load virtualenvwrapper" "typeset -f $name | grep 'virtualenvwrapper_load'"
26+
if [ "$name" = "mkvirtualenv" ]
27+
then
28+
lookfor="rmvirtualenv"
29+
else
30+
lookfor="mkvirtualenv"
31+
fi
32+
assertFalse "$name includes reference to $lookfor: $(typeset -f $name)" "typeset -f $name | grep $lookfor"
2533
}
2634

2735
test_mkvirtualenv_defined_lazy() {

virtualenvwrapper_lazy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ function virtualenvwrapper_load {
2020
# Set up "alias" functions based on the API definition.
2121
function virtualenvwrapper_setup_lazy_loader {
2222
typeset venvw_name
23-
for venvw_name in $_VIRTUALENVWRAPPER_API
23+
for venvw_name in $(echo ${_VIRTUALENVWRAPPER_API})
2424
do
2525
eval "
2626
function $venvw_name {
2727
virtualenvwrapper_load
28-
$venvw_name \"\$@\"
28+
${venvw_name} \"\$@\"
2929
}
3030
"
3131
done

0 commit comments

Comments
 (0)