Skip to content

Commit 719b251

Browse files
committed
Escape uses of cd in case it is aliased. addresses #101
1 parent f09399e commit 719b251

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

virtualenvwrapper.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ mkvirtualenv () {
270270
virtualenvwrapper_verify_virtualenv || return 1
271271
(
272272
[ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT
273-
cd "$WORKON_HOME" &&
273+
\cd "$WORKON_HOME" &&
274274
"$VIRTUALENVWRAPPER_VIRTUALENV" $VIRTUALENVWRAPPER_VIRTUALENV_ARGS "$@" &&
275275
[ -d "$WORKON_HOME/$envname" ] && \
276276
virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname"
@@ -307,7 +307,7 @@ rmvirtualenv () {
307307
# Move out of the current directory to one known to be
308308
# safe, in case we are inside the environment somewhere.
309309
typeset prior_dir="$(pwd)"
310-
cd "$WORKON_HOME"
310+
\cd "$WORKON_HOME"
311311

312312
virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name"
313313
\rm -rf "$env_dir"
@@ -316,7 +316,7 @@ rmvirtualenv () {
316316
# If the directory we used to be in still exists, move back to it.
317317
if [ -d "$prior_dir" ]
318318
then
319-
cd "$prior_dir"
319+
\cd "$prior_dir"
320320
fi
321321
}
322322

@@ -326,9 +326,9 @@ virtualenvwrapper_show_workon_options () {
326326
# NOTE: DO NOT use ls here because colorized versions spew control characters
327327
# into the output list.
328328
# echo seems a little faster than find, even with -depth 3.
329-
(cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$')
329+
(\cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$')
330330

331-
# (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort
331+
# (\cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort
332332
}
333333

334334
_lsvirtualenv_usage () {
@@ -532,14 +532,14 @@ cdsitepackages () {
532532
virtualenvwrapper_verify_workon_home || return 1
533533
virtualenvwrapper_verify_active_environment || return 1
534534
typeset site_packages="`virtualenvwrapper_get_site_packages_dir`"
535-
cd "$site_packages"/$1
535+
\cd "$site_packages"/$1
536536
}
537537

538538
# Does a ``cd`` to the root of the currently-active virtualenv.
539539
cdvirtualenv () {
540540
virtualenvwrapper_verify_workon_home || return 1
541541
virtualenvwrapper_verify_active_environment || return 1
542-
cd $VIRTUAL_ENV/$1
542+
\cd $VIRTUAL_ENV/$1
543543
}
544544

545545
# Shows the content of the site-packages directory of the currently-active
@@ -615,7 +615,7 @@ cpvirtualenv() {
615615
"$VIRTUALENVWRAPPER_VIRTUALENV" "$target_env" --relocatable
616616
\sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/bin/activate"
617617

618-
(cd "$WORKON_HOME" && (
618+
(\cd "$WORKON_HOME" && (
619619
virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env";
620620
virtualenvwrapper_run_hook "pre_mkvirtualenv" "$new_env"
621621
))

0 commit comments

Comments
 (0)