Do not allow whitespace in VIRTUALENV_NAME

While this could work in general, it fails in the end, because
whitespace is not allowed/supported in the shebang line with the
scripts in the created virtualenv.
This commit is contained in:
Daniel Hahler
2014-09-03 23:28:46 +02:00
parent 2cc21f112c
commit 86046fd4e8
2 changed files with 23 additions and 0 deletions

View File

@@ -297,6 +297,11 @@ if [ -z "${VERSION_NAME}" ] || [ -z "${VIRTUALENV_NAME}" ]; then
usage 1
fi
if [ "$VIRTUALENV_NAME" != "${VIRTUALENV_NAME%[[:space:]]*}" ]; then
echo "pyenv-virtualenv: no whitespace allowed in virtualenv name." 1>&2
exit 1
fi
# Set VERSION_NAME as default version in this script
export PYENV_VERSION="${VERSION_NAME}"

View File

@@ -132,3 +132,21 @@ OUT
unstub pyenv-exec
unstub curl
}
@test "no whitespace allowed in virtualenv name" {
run pyenv-virtualenv "3.2.1" "foo bar"
assert_failure
assert_output <<OUT
pyenv-virtualenv: no whitespace allowed in virtualenv name.
OUT
}
@test "no tab allowed in virtualenv name" {
run pyenv-virtualenv "3.2.1" "foo bar baz"
assert_failure
assert_output <<OUT
pyenv-virtualenv: no whitespace allowed in virtualenv name.
OUT
}