mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
Reliably detect parent shell in pyenv init
(fixes #93)
Imported changes from sstephenson/rbenv#453.
This commit is contained in:
parent
6efb3c327f
commit
5bff9c773a
3 changed files with 23 additions and 9 deletions
|
@ -22,7 +22,9 @@ done
|
||||||
|
|
||||||
shell="$1"
|
shell="$1"
|
||||||
if [ -z "$shell" ]; then
|
if [ -z "$shell" ]; then
|
||||||
shell="$(basename "$SHELL")"
|
shell="$(ps c -p $(ps -p $$ -o 'ppid=' 2>/dev/null) -o 'comm=' 2>/dev/null || true)"
|
||||||
|
shell="${shell##-}"
|
||||||
|
shell="$(basename "${shell:-$SHELL}")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
READLINK=$(type -p greadlink readlink | head -1)
|
READLINK=$(type -p greadlink readlink | head -1)
|
||||||
|
@ -75,7 +77,7 @@ if [ -z "$print" ]; then
|
||||||
echo
|
echo
|
||||||
case "$shell" in
|
case "$shell" in
|
||||||
fish )
|
fish )
|
||||||
echo '. (pyenv init -|psub)'
|
echo 'status --is-interactive; and . (pyenv init -|psub)'
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
echo 'eval "$(pyenv init -)"'
|
echo 'eval "$(pyenv init -)"'
|
||||||
|
@ -100,8 +102,22 @@ if [[ ":${PATH}:" != *:"${PYENV_ROOT}/shims":* ]]; then
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
case "$shell" in
|
||||||
|
fish )
|
||||||
|
echo "setenv PYENV_SHELL $shell"
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "export PYENV_SHELL=$shell"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
completion="${root}/completions/pyenv.${shell}"
|
completion="${root}/completions/pyenv.${shell}"
|
||||||
[ -r "$completion" ] && echo ". '$completion'"
|
if [ -r "$completion" ]; then
|
||||||
|
case "$shell" in
|
||||||
|
fish ) echo ". '$completion'" ;;
|
||||||
|
* ) echo "source '$completion'" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$no_rehash" ]; then
|
if [ -z "$no_rehash" ]; then
|
||||||
echo 'pyenv rehash 2>/dev/null'
|
echo 'pyenv rehash 2>/dev/null'
|
||||||
|
|
|
@ -7,7 +7,7 @@ if [ "$1" = "--complete" ]; then
|
||||||
exec pyenv-rehash --complete
|
exec pyenv-rehash --complete
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shell="$(basename "$SHELL")"
|
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
|
||||||
|
|
||||||
# When pyenv shell integration is enabled, delegate to pyenv-rehash,
|
# When pyenv shell integration is enabled, delegate to pyenv-rehash,
|
||||||
# then tell the shell to empty its command lookup cache.
|
# then tell the shell to empty its command lookup cache.
|
||||||
|
@ -15,11 +15,9 @@ pyenv-rehash
|
||||||
|
|
||||||
case "$shell" in
|
case "$shell" in
|
||||||
fish )
|
fish )
|
||||||
or='; or'
|
# no rehash support
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
or='||'
|
echo "hash -r 2>/dev/null || true"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "hash -r 2>/dev/null $or true"
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ if [ "$1" = "--complete" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
versions=("$@")
|
versions=("$@")
|
||||||
shell="$(basename "$SHELL")"
|
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
|
||||||
|
|
||||||
if [ -z "$versions" ]; then
|
if [ -z "$versions" ]; then
|
||||||
if [ -z "$PYENV_VERSION" ]; then
|
if [ -z "$PYENV_VERSION" ]; then
|
||||||
|
|
Loading…
Reference in a new issue