1) Got rid of useless call to `cat`, much better to simply use sed with
file as argument.
2) Got rid of `sort -u`. There is no need to sort the list.
Additionally, the list `pyenv.d/rehash/conda.d/default.list` only has
unique entries, and even if you have duplicate entries, the function
will still work. --> No need for sort nor unique.
3) Further improvement is simple, save a cached
cleaned-list-v1.0 in `conda.d` and simple read from that file instead of
doing `sed`, which must be a more expensive operation than simply
reading from file.
Applies to the conda blacklist in `pyenv.d/rehash/conda.d/default.list`
No practical difference, but it looks misplaced when it sits at the end
of the file.
I was doing some debugging with PYENV_DEBUG=1 and noticed that a lot of
work was being done in conda.bash, even though I had not installed any
conda versions like `mambaforge`.
The solution is pretty simple, put all the code inside an if-block.
This aligns with what @varikin found in his pull request #3037
Additionally, I have refactored the code slightly for readability
(created function `build_conda_exclusion_list`), and added comments
which should make it easier to understand what's going on.
This commit simplifies debugging and should reduce the execution time of
```bash
eval "$(pyenv init -)"
```
slightly.
According to the POSIX spec, an unescaped backslash not followed by
an escapable character is undefined behavior,
and it has become an error in GNU grep 3.8 (2022-09-02).
infocmp is a system utility that returns information about the user's terminal. When it is shimmed it can cause problems for various programs that use it to determine terminal settings. In particular, the library used by the Scala shell reads it and problems can occur where various control keys don't work (e.g. backspace does not work).
All scripts in libexec/ (excluding pyenv) are called through pyenv,
therefore the shebang lines are not necessary. On some systems this
provides a measurable increase in performance of the shell prompt.
Related to pyenv/pyenv-virtualenv#259
Add `clear` to the Anaconda's default blacklist in order to prevent
pyenv from creating the shim script for it.
The `clear` command executable began included from Anaconda 5.0.0
onwards, and this executable now conceals that of the user's base system
- this hinders the user from running the `clear` command with the
`command not found` error output if a user installs and selects one or
more Python version(s) other than Anaconda 5.x.x.
Adding this one-liner to the blacklist allows the user to use the
`clear` command even when Anaconda 5.x.x is not selected by pyenv.
Add `tput` to the Anaconda's default blacklist in order to prevent pyenv
from creating the shim script for it.
Anaconda 5.0.0 contains some executables which are part of the base
system. Many of these executables did not exist in the last major
version of Anaconda (`4.4.0`), and the existence of pyenv's shim
scripts for these executables in `5.0.0` can cause to conceal those
executables in the user's base system; for the details, please see the
discussion with @yyuu at #992.
This commit resolves a coloured output error when running a terminal
command which uses `tput`. This error occurs when multiple Python
versions are installed alongside `anaconda2-5.0.0` or `anaconda3-5.0.0`
and neither of those two Anaconda versions is selected by pyenv.
The performance issue must be caused by too many I/O requests to
`conda.txt` from fgrep. This inline expansion should work to reduce # of
read to the `conda.txt`.
original performance:
```
% git rev-parse HEAD
4f76be6a129a7281a41780783eefdab3ec472a40
% time bash -c 'pyenv rehash'
bash -c 'pyenv rehash' 0.05s user 0.02s system 76% cpu 0.089 total
```
previous commit: ==> 4x slower than original
```
% git rev-parse HEAD
4469d51ef7bb3e2907f5a363bb97d92896628527
% time bash -c 'pyenv rehash'
bash -c 'pyenv rehash' 0.06s user 0.03s system 25% cpu 0.358 total
```
with this workaround: ==> almost same as original
```
% git rev-parse HEAD
3ffe91bdbc69220eaecf6e2088229cc27366c3f3
% time bash -c 'pyenv rehash'
bash -c 'pyenv rehash' 0.05s user 0.00s system 68% cpu 0.082 total
```