mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
878bd87328
`$SHELL` variable is a terrible way of detecting the current shell because it's not even supposed to reflect the current shell; it's meant for keeping the value of the default shell for programs to start. If an explicit `<shell>` argument wasn't passed to `rbenv init`, it tries to detect the shell by getting the name of its parent process. If this fails, it falls back on the value of `$SHELL` as before. Furthermore, `rbenv init` will set the RBENV_SHELL variable in the current shell to the value of the detected shell so that `sh-shell` and `sh-rehash` commands don't have to repeat the detection.
25 lines
444 B
Bash
Executable file
25 lines
444 B
Bash
Executable file
#!/usr/bin/env bash
|
|
set -e
|
|
[ -n "$RBENV_DEBUG" ] && set -x
|
|
|
|
# Provide rbenv completions
|
|
if [ "$1" = "--complete" ]; then
|
|
exec rbenv-rehash --complete
|
|
fi
|
|
|
|
shell="$(basename "${RBENV_SHELL:-$SHELL}")"
|
|
|
|
# When rbenv shell integration is enabled, delegate to rbenv-rehash,
|
|
# then tell the shell to empty its command lookup cache.
|
|
rbenv-rehash
|
|
|
|
case "$shell" in
|
|
fish )
|
|
or='; or'
|
|
;;
|
|
* )
|
|
or='||'
|
|
;;
|
|
esac
|
|
|
|
echo "hash -r 2>/dev/null $or true"
|