Skip to content

Commit 5d7894d

Browse files
committed
fix: PATH update for non-fish shells
Checks PATH variable for existing inclusion of shims for shells other than fish. See PR #430
1 parent 2b2b87a commit 5d7894d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Diff for: bin/pyenv-virtualenv-init

+4-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ EOS
9595
;;
9696
* )
9797
cat <<EOS
98-
export PATH="${PYENV_VIRTUALENV_ROOT:-${PYENV_VIRTUALENV_INSTALL_PREFIX}}/shims:\${PATH}";
99-
export PYENV_VIRTUALENV_INIT=1;
98+
if [[ ":$PATH:" != *"${PYENV_VIRTUALENV_ROOT:-${PYENV_VIRTUALENV_INSTALL_PREFIX}}/shims"* ]]; then
99+
export PATH="${PYENV_VIRTUALENV_ROOT:-${PYENV_VIRTUALENV_INSTALL_PREFIX}}/shims:\${PATH}";
100+
export PYENV_VIRTUALENV_INIT=1;
101+
fi
100102
EOS
101103
;;
102104
esac

Diff for: test/init.bats

+8-4
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ load test_helper
5050
run pyenv-virtualenv-init - bash
5151
assert_success
5252
assert_output <<EOS
53-
export PATH="${TMP}/pyenv/plugins/pyenv-virtualenv/shims:\${PATH}";
54-
export PYENV_VIRTUALENV_INIT=1;
53+
if [[ ":$PATH:" != *"${TMP}/pyenv/plugins/pyenv-virtualenv/shims"* ]]; then
54+
export PATH="${TMP}/pyenv/plugins/pyenv-virtualenv/shims:\${PATH}";
55+
export PYENV_VIRTUALENV_INIT=1;
56+
fi
5557
_pyenv_virtualenv_hook() {
5658
local ret=\$?
5759
if [ -n "\${VIRTUAL_ENV-}" ]; then
@@ -93,8 +95,10 @@ EOS
9395
run pyenv-virtualenv-init - zsh
9496
assert_success
9597
assert_output <<EOS
96-
export PATH="${TMP}/pyenv/plugins/pyenv-virtualenv/shims:\${PATH}";
97-
export PYENV_VIRTUALENV_INIT=1;
98+
if [[ ":$PATH:" != *"${TMP}/pyenv/plugins/pyenv-virtualenv/shims"* ]]; then
99+
export PATH="${TMP}/pyenv/plugins/pyenv-virtualenv/shims:\${PATH}";
100+
export PYENV_VIRTUALENV_INIT=1;
101+
fi
98102
_pyenv_virtualenv_hook() {
99103
local ret=\$?
100104
if [ -n "\${VIRTUAL_ENV-}" ]; then

0 commit comments

Comments
 (0)