Alex Hedges 54c51d8f87 Handle case where pyenv-commands --sh returns nothing
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.
2024-02-25 15:02:41 -05:00
..
2024-02-14 00:58:44 +03:00
2021-02-23 22:29:56 +02:00