Skip to content

Commit 6570539

Browse files
committed
add -q option to cd for zsh
fixes bug #242 Change-Id: I7176290b6d49a0420adea805549d3896c37b95b3
1 parent a0e73c9 commit 6570539

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

tests/test_cd_alias.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ oneTimeSetUp() {
1010
source "$test_dir/../virtualenvwrapper.sh"
1111
mkvirtualenv cd-test >/dev/null 2>&1
1212
deactivate
13-
alias cd='fail "Should not be using override cd function"'
1413
}
1514

1615
oneTimeTearDown() {
@@ -27,10 +26,27 @@ tearDown () {
2726
}
2827

2928
test_cd() {
29+
alias cd='fail "Should not be using override cd function"'
3030
start_dir="$(pwd)"
3131
virtualenvwrapper_cd "$VIRTUAL_ENV"
3232
assertSame "$VIRTUAL_ENV" "$(pwd)"
3333
virtualenvwrapper_cd "$start_dir"
34+
unalias cd
35+
}
36+
37+
# Define hook function to make cd break
38+
chpwd () {
39+
return 1
40+
}
41+
# Run a test that uses cd to ensure the hook is not called
42+
test_cd_zsh_chpwd_not_called () {
43+
if [ -n "$ZSH_VERSION" ]; then
44+
start_dir="$(pwd)"
45+
virtualenvwrapper_cd "$VIRTUAL_ENV"
46+
assertSame "$VIRTUAL_ENV" "$(pwd)"
47+
virtualenvwrapper_cd "$start_dir"
48+
fi
49+
unset -f chpwd >/dev/null 2>&1
3450
}
3551

3652
. "$test_dir/shunit2"

virtualenvwrapper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function virtualenvwrapper_cd {
109109
builtin \cd "$@"
110110
elif [ -n "$ZSH_VERSION" ]
111111
then
112-
builtin \cd "$@"
112+
builtin \cd -q "$@"
113113
else
114114
command \cd "$@"
115115
fi

0 commit comments

Comments
 (0)