From c64aebef08529cd65b505f5d8bb326930775b378 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Mon, 2 May 2016 01:07:48 +0000 Subject: [PATCH] 1) Made `--quiet` as opposite of `--verbose` 2) Suppress warning about prompts on `--quiet` --- bin/pyenv-sh-activate | 13 ++++++++----- bin/pyenv-sh-deactivate | 3 +-- test/activate.bats | 27 ++++++++++++++++++++++++++- test/deactivate.bats | 30 ++++++++++++++++++++++++++++++ test/init.bats | 0 5 files changed, 65 insertions(+), 8 deletions(-) mode change 100755 => 100644 test/init.bats diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index 8beb631..d2f4081 100755 --- a/bin/pyenv-sh-activate +++ b/bin/pyenv-sh-activate @@ -24,7 +24,6 @@ resolve_link() { unset FORCE unset QUIET -unset VERBOSE while [ $# -gt 0 ]; do case "$1" in @@ -47,7 +46,7 @@ while [ $# -gt 0 ]; do exec pyenv-sh-deactivate ;; "-v" | "--verbose" ) - VERBOSE=1 + unset QUIET ;; * ) break @@ -136,7 +135,7 @@ if [[ "${VIRTUAL_ENV}" == "${prefix}" ]]; then fi fi -pyenv-sh-deactivate --force --quiet ${VERBOSE+--verbose} || true +pyenv-sh-deactivate --force --quiet || true if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then echo "pyenv-virtualenv: activate ${venv}" 1>&2 @@ -220,10 +219,14 @@ PYENV_VIRTUALENV_DISABLE_PROMPT="${PYENV_VIRTUALENV_DISABLE_PROMPT:-${VIRTUAL_EN if [ -z "${PYENV_VIRTUALENV_DISABLE_PROMPT}" ]; then case "${shell}" in fish ) - echo "pyenv-virtualenv: prompt changing not working for fish." 1>&2 + if [ -z "${QUIET}" ]; then + echo "pyenv-virtualenv: prompt changing not working for fish." 1>&2 + fi ;; * ) - echo "pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior." 1>&2 + if [ -z "${QUIET}" ]; then + echo "pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior." 1>&2 + fi cat </dev/null 2>&1; then + unset -f deactivate; +fi; +EOS +} + @test "deactivate virtualenv (verbose)" { export PYENV_VIRTUALENV_INIT=1 export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv" diff --git a/test/init.bats b/test/init.bats old mode 100755 new mode 100644