Skip to content

Commit 04fdc9e

Browse files
committed
Quote paths.
Ensure that variables building paths from subcommands are quoted in case the paths include spaces. addresses issue #164
1 parent ea5344f commit 04fdc9e

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

docs/source/history.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Release History
33
===============
44

5+
dev
6+
===
7+
8+
- Ensure that all $() style commands that produce paths are
9+
quoted. Addresses :bbissue:`164`.
10+
511
4.0
612
===
713

virtualenvwrapper.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function virtualenvwrapper_derive_workon_home {
146146
# - Removing extra slashes (e.g., when TMPDIR ends in a slash)
147147
# - Expanding variables (e.g., $foo)
148148
# - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur)
149-
workon_home_dir=$(virtualenvwrapper_expandpath "$workon_home_dir")
149+
workon_home_dir="$(virtualenvwrapper_expandpath "$workon_home_dir")"
150150
fi
151151

152152
echo "$workon_home_dir"
@@ -297,7 +297,7 @@ function virtualenvwrapper_initialize {
297297

298298
# Verify that the passed resource is in path and exists
299299
function virtualenvwrapper_verify_resource {
300-
typeset exe_path=$(command \which "$1" | (unset GREP_OPTIONS; command \grep -v "not found"))
300+
typeset exe_path="$(command \which "$1" | (unset GREP_OPTIONS; command \grep -v "not found"))"
301301
if [ "$exe_path" = "" ]
302302
then
303303
echo "ERROR: virtualenvwrapper could not find $1 in your path" >&2
@@ -411,11 +411,11 @@ function mkvirtualenv {
411411
-p|--python)
412412
i=$(( $i + 1 ));
413413
interpreter="${in_args[$i]}";
414-
interpreter=$(virtualenvwrapper_absolutepath "$interpreter");;
414+
interpreter="$(virtualenvwrapper_absolutepath "$interpreter")";;
415415
-r)
416416
i=$(( $i + 1 ));
417417
requirements="${in_args[$i]}";
418-
requirements=$(virtualenvwrapper_expandpath "$requirements");;
418+
requirements="$(virtualenvwrapper_expandpath "$requirements")";;
419419
*)
420420
if [ ${#out_args} -gt 0 ]
421421
then
@@ -608,7 +608,7 @@ function showvirtualenv {
608608
echo "showvirtualenv [env]"
609609
return 1
610610
fi
611-
env_name=$(basename $VIRTUAL_ENV)
611+
env_name=$(basename "$VIRTUAL_ENV")
612612
fi
613613

614614
echo -n "$env_name"
@@ -797,7 +797,7 @@ function add2virtualenv {
797797

798798
for pydir in "$@"
799799
do
800-
absolute_path=$(virtualenvwrapper_absolutepath "$pydir")
800+
absolute_path="$(virtualenvwrapper_absolutepath "$pydir")"
801801
if [ "$absolute_path" != "$pydir" ]
802802
then
803803
echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2
@@ -884,13 +884,13 @@ function cpvirtualenv {
884884
# so its a virtualenv we are importing
885885
# make sure we have a full path
886886
# and get the name
887-
src=$(virtualenvwrapper_expandpath "$src_name")
887+
src="$(virtualenvwrapper_expandpath "$src_name")"
888888
# final verification
889889
if [ ! -e "$src" ]; then
890890
echo "Please provide a valid virtualenv to copy."
891891
return 1
892892
fi
893-
src_name=$(basename "$src")
893+
src_name="$(basename "$src")"
894894
else
895895
src="$WORKON_HOME/$src_name"
896896
fi
@@ -904,7 +904,7 @@ function cpvirtualenv {
904904
else
905905
trg="$WORKON_HOME/$trg_name"
906906
fi
907-
trg=$(virtualenvwrapper_expandpath "$trg")
907+
trg="$(virtualenvwrapper_expandpath "$trg")"
908908

909909
# validate trg does not already exist
910910
# catch copying virtualenv in workon home
@@ -1075,7 +1075,7 @@ function cdproject {
10751075
virtualenvwrapper_verify_active_environment || return 1
10761076
if [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ]
10771077
then
1078-
typeset project_dir=$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME")
1078+
typeset project_dir="$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME")"
10791079
if [ ! -z "$project_dir" ]
10801080
then
10811081
cd "$project_dir"

0 commit comments

Comments
 (0)