From 86046fd4e8926824abd55a3d8d3a6f852ab20195 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 3 Sep 2014 23:28:46 +0200 Subject: [PATCH] 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. --- bin/pyenv-virtualenv | 5 +++++ test/virtualenv.bats | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index e1cad68..7e1644b 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -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}" diff --git a/test/virtualenv.bats b/test/virtualenv.bats index 0b3796e..7a0d7e5 100644 --- a/test/virtualenv.bats +++ b/test/virtualenv.bats @@ -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 <