Skip to content

Commit 7958430

Browse files
committed
Made lsvirtualenv and allvirtualenv work with spaces in env names
1 parent 6443c18 commit 7958430

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

tests/test_allvirtualenv.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ oneTimeSetUp() {
1010
source "$test_dir/../virtualenvwrapper.sh"
1111
mkvirtualenv test1 >/dev/null 2>&1
1212
mkvirtualenv test2 >/dev/null 2>&1
13+
mkvirtualenv " env with space " >/dev/null 2>&1
1314
deactivate
1415
}
1516

@@ -28,6 +29,8 @@ tearDown () {
2829
test_allvirtualenv_all() {
2930
assertTrue "Did not find test1" "allvirtualenv pwd | grep -q 'test1$'"
3031
assertTrue "Did not find test2" "allvirtualenv pwd | grep -q 'test2$'"
32+
allvirtualenv pwd
33+
assertTrue "Did not find ' env with space '" "allvirtualenv pwd | grep -q ' env with space '"
3134
}
3235

3336
test_allvirtualenv_spaces() {

tests/test_ls.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,11 @@ test_lsvirtualenv_space_in_workon_home () {
7575
WORKON_HOME="$old_home"
7676
}
7777

78+
test_lsvirtualenv_space_in_env_name () {
79+
mkvirtualenv " env with space "
80+
lsvirtualenv -b >"$WORKON_HOME/output" 2>&1
81+
assertTrue "Did not see expected message in \"$output\"" "cat \"$WORKON_HOME/output\" | grep -q ' env with space '"
82+
}
83+
7884

7985
. "$test_dir/shunit2"

virtualenvwrapper.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,9 @@ function virtualenvwrapper_show_workon_options {
569569
# 5. Eliminate any lines with * on them because that means there
570570
# were no envs.
571571
(virtualenvwrapper_cd "$WORKON_HOME" && echo */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate) 2>/dev/null \
572-
| command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||g" \
573-
| command \fmt -w 1 \
572+
| command \tr "\n" " " \
573+
| command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate |/|g" \
574+
| command \tr "/" "\n" \
574575
| (unset GREP_OPTIONS; command \egrep -v '^\*$') 2>/dev/null
575576
}
576577

@@ -1292,6 +1293,7 @@ function allvirtualenv {
12921293
virtualenvwrapper_verify_workon_home || return 1
12931294
typeset d
12941295

1296+
IFS=''
12951297
virtualenvwrapper_show_workon_options | while read d
12961298
do
12971299
[ ! -d "$WORKON_HOME/$d" ] && continue
@@ -1304,6 +1306,7 @@ function allvirtualenv {
13041306
"$@")
13051307
echo
13061308
done
1309+
unset IFS
13071310
}
13081311

13091312
#:help:virtualenvwrapper: show this help message

0 commit comments

Comments
 (0)