Merge pull request #44 from blueyed/no-whitespace-in-name

Do not allow whitespace in VIRTUALENV_NAME
This commit is contained in:
Yamashita, Yuu
2014-09-04 08:56:44 +09:00
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 usage 1
fi 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 # Set VERSION_NAME as default version in this script
export PYENV_VERSION="${VERSION_NAME}" export PYENV_VERSION="${VERSION_NAME}"

View File

@@ -132,3 +132,21 @@ OUT
unstub pyenv-exec unstub pyenv-exec
unstub curl 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
}