Reuse the bash init code from pyenv-init
Merged
IG
10d ago+17+17+01234567890123456789-0-0-0123456789
Following the discussion here I reused the code that prevents duplicate path segments from pyenv init, only changed it from multiple echos to heredoc.
I can't say that I'm a fan of this code
- It's way too complex;
- It invokes Bash on some the other shells, e.g.
pyenv init - zsh->
PATH="$(bash --norc -ec 'IFS=:; paths=($PATH);
...
which is not good. Unit test in pyenv init is more relaxed than here and don't catch it.
.. But if this code was accepted in pyenv init, it should be good as well here ๐
Summary by cubic
Reuses the duplicate-path cleanup logic from pyenv init in pyenv-virtualenv-init for bash, so repeated initialization no longer accumulates duplicate shims entries in PATH.
- Removes any existing shims path from
PATHbefore prepending it. - Updates the bash init test to match the new output.