From c1b9238cbe32aed8fb618ec65798b596d2aae0d3 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Sun, 8 Nov 2015 23:44:58 +0000 Subject: [PATCH] Reject creating a virtualenv named `system` (yyuu/pyenv#475) --- bin/pyenv-virtualenv | 5 +++++ test/virtualenv.bats | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index bedbb69..07b9323 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -273,6 +273,11 @@ if [ -z "${VERSION_NAME}" ] || [ -z "${VIRTUALENV_NAME}" ]; then usage 1 fi +if [[ "$VIRTUALENV_NAME" == "system" ]]; then + echo "pyenv-virtualenv: \`system' is not allowed as virtualenv name." 1>&2 + exit 1 +fi + if [ "$VIRTUALENV_NAME" != "${VIRTUALENV_NAME%[[:space:]]*}" ]; then echo "pyenv-virtualenv: no whitespace allowed in virtualenv name." 1>&2 exit 1 diff --git a/test/virtualenv.bats b/test/virtualenv.bats index 79468b6..1fc29f9 100644 --- a/test/virtualenv.bats +++ b/test/virtualenv.bats @@ -135,3 +135,12 @@ OUT pyenv-virtualenv: no whitespace allowed in virtualenv name. OUT } + +@test "system not allowed as virtualenv name" { + run pyenv-virtualenv "3.2.1" "system" + + assert_failure + assert_output <