When running `eval "$(pyenv init -)"` to initialize `pyenv`, the command
generates a shell script to be executed. When not using the `fish`
shell, this script contains a `case` statement where the first case
matches against the output of `pyenv-commands --sh` and the second case
handles everything else. However, if no commands are returned, then the
matching expression will be only `)`, which is invalid Bash.
I have solved this (on the advice of @ native-api) by using the string
`/` if there are no commands to include. `/` is the only character in
Linux/POSIX besides `\0` that a filename cannot contain, so it is safe
to use as a pattern that will never match. To catch any regressions, I
have added a test to catch unexpected changes in the generated `case`
statement. I copied the `create_executable` function from `latest.bats`
because I needed to shim `pyenv-commands`.
I do not know if `pyenv-commands --sh` can ever return nothing under
normal conditions, but it happened to me due to completely unrelated
problems in underlying Unix utilities called by `pyenv`. Although this
bug will rarely occur, I feel that this increased robustness will be
useful.
* Support ksh versions
Korn shell had two major versions: ’88 and ’93. Some systems have
ksh installed under the name `ksh93`. A few systems (maybe only
Solaris now) also have a `ksh88`. A few others use the `pdksh` (’88)
or `mksh` (’93) implementations, originated before ksh was open source.
Limit to currently-used versions
---------
Co-authored-by: Kevin Schoedel <kps@datatravelandexperiments.com>
* Remove all use of `greadlink`, fix#2654
Signed-off-by: Harry Chen <i@harrychen.xyz>
* revert greadlink back in tests
---------
Signed-off-by: Harry Chen <i@harrychen.xyz>
Co-authored-by: Anton Petrov <anton.a.petrov@gmail.com>
In some advanced shell setups, the order of custom-added PATH entries is important.
We disregard it by default, always pushing shims to the front of PATH,
to ensure that Pyenv works even in poorly maintained shell environments
and with minimal hassle for non-export users
(an attempt to do the opposite (#1898) has ended in a disaster).
Some advanced users are however ready and able to carefully maintain their environment
and deal with breakages and inconvenience. This option is for them.