From 2662b5807cd25afafdca49240209f6083de0d3fa Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 13 Aug 2014 00:55:04 +0100 Subject: [PATCH 1/4] Fix weird bash code issue which made bash complain about "then" --- bin/pyenv-virtualenv-init | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index c0a4b1b..5016537 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -110,21 +110,21 @@ esac if [[ "$shell" != "fish" ]]; then cat < Date: Wed, 13 Aug 2014 03:40:02 +0100 Subject: [PATCH 2/4] `if [ pyenv deactivate --no-error --verbose ]` is not bourne shell compatible --- bin/pyenv-virtualenv-init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 5016537..1ab8edb 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -115,7 +115,7 @@ if [[ "$shell" != "fish" ]]; then return 0 fi if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix)" ]; then - if [ pyenv deactivate --no-error --verbose ]; then + if pyenv deactivate --no-error --verbose; then pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE else pyenv activate --no-error --verbose From 7304608e0f47495632f6023a19d5888c377b5b95 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 13 Aug 2014 03:58:32 +0100 Subject: [PATCH 3/4] Adapt tests to new output --- test/init.bats | 52 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/test/init.bats b/test/init.bats index 3489357..e03b52a 100644 --- a/test/init.bats +++ b/test/init.bats @@ -32,21 +32,21 @@ load test_helper export PYENV_VIRTUALENV_INIT=1; _pyenv_virtualenv_hook() { if [ -n "\$PYENV_ACTIVATE" ]; then - if [ "x\`pyenv version-name\`" = "xsystem" ]; then - pyenv deactivate --no-error --verbose - return 0 - fi - if [ "x\$PYENV_ACTIVATE" != "x\`pyenv prefix\`" ]; then - if pyenv deactivate --no-error --verbose; then - pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE - else + if [ "\$(pyenv version-name)" = "system" ]; then + pyenv deactivate --no-error --verbose + return 0 + fi + if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix)" ]; then + if pyenv deactivate --no-error --verbose; then + pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE + else + pyenv activate --no-error --verbose + fi + fi + else + if [ -z "\$VIRTUAL_ENV" ] && [ "\$PYENV_DEACTIVATE" != "\$(pyenv prefix)" ]; then pyenv activate --no-error --verbose fi - fi - else - if [ -z "\$VIRTUAL_ENV" ] && [ "x\$PYENV_DEACTIVATE" != "x\`pyenv prefix\`" ]; then - pyenv activate --no-error --verbose - fi fi }; if ! [[ "\$PROMPT_COMMAND" =~ _pyenv_virtualenv_hook ]]; then @@ -89,21 +89,21 @@ EOS export PYENV_VIRTUALENV_INIT=1; _pyenv_virtualenv_hook() { if [ -n "\$PYENV_ACTIVATE" ]; then - if [ "x\`pyenv version-name\`" = "xsystem" ]; then - pyenv deactivate --no-error --verbose - return 0 - fi - if [ "x\$PYENV_ACTIVATE" != "x\`pyenv prefix\`" ]; then - if pyenv deactivate --no-error --verbose; then - pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE - else + if [ "\$(pyenv version-name)" = "system" ]; then + pyenv deactivate --no-error --verbose + return 0 + fi + if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix)" ]; then + if pyenv deactivate --no-error --verbose; then + pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE + else + pyenv activate --no-error --verbose + fi + fi + else + if [ -z "\$VIRTUAL_ENV" ] && [ "\$PYENV_DEACTIVATE" != "\$(pyenv prefix)" ]; then pyenv activate --no-error --verbose fi - fi - else - if [ -z "\$VIRTUAL_ENV" ] && [ "x\$PYENV_DEACTIVATE" != "x\`pyenv prefix\`" ]; then - pyenv activate --no-error --verbose - fi fi }; typeset -a precmd_functions From 81736da90534eb8511890a4e3c52b06f220db124 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 13 Aug 2014 19:51:22 +0100 Subject: [PATCH 4/4] Indent to 2 spaces. --- bin/pyenv-virtualenv-init | 26 ++++++++++---------- test/init.bats | 52 +++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 1ab8edb..62a221e 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -110,21 +110,21 @@ esac if [[ "$shell" != "fish" ]]; then cat <