Просмотр исходного кода

Reliably detect parent shell in `pyenv init` (fixes #93)

Imported changes from sstephenson/rbenv#453.
Yamashita Yuu 12 лет назад
Родитель
Сommit
5bff9c773a
3 измененных файлов: 23 добавлений и 9 удалений
  1. +19
    -3
      libexec/pyenv-init
  2. +3
    -5
      libexec/pyenv-sh-rehash
  3. +1
    -1
      libexec/pyenv-sh-shell

+ 19
- 3
libexec/pyenv-init Просмотреть файл

@ -22,7 +22,9 @@ done
shell="$1"
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
READLINK=$(type -p greadlink readlink | head -1)
@ -75,7 +77,7 @@ if [ -z "$print" ]; then
echo
case "$shell" in
fish )
echo '. (pyenv init -|psub)'
echo 'status --is-interactive; and . (pyenv init -|psub)'
;;
* )
echo 'eval "$(pyenv init -)"'
@ -100,8 +102,22 @@ if [[ ":${PATH}:" != *:"${PYENV_ROOT}/shims":* ]]; then
esac
fi
case "$shell" in
fish )
echo "setenv PYENV_SHELL $shell"
;;
* )
echo "export PYENV_SHELL=$shell"
;;
esac
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
echo 'pyenv rehash 2>/dev/null'

+ 3
- 5
libexec/pyenv-sh-rehash Просмотреть файл

@ -7,7 +7,7 @@ if [ "$1" = "--complete" ]; then
exec pyenv-rehash --complete
fi
shell="$(basename "$SHELL")"
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
# When pyenv shell integration is enabled, delegate to pyenv-rehash,
# then tell the shell to empty its command lookup cache.
@ -15,11 +15,9 @@ pyenv-rehash
case "$shell" in
fish )
or='; or'
# no rehash support
;;
* )
or='||';
echo "hash -r 2>/dev/null || true";
;;
esac
echo "hash -r 2>/dev/null $or true"

+ 1
- 1
libexec/pyenv-sh-shell Просмотреть файл

@ -24,7 +24,7 @@ if [ "$1" = "--complete" ]; then
fi
versions=("$@")
shell="$(basename "$SHELL")"
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
if [ -z "$versions" ]; then
if [ -z "$PYENV_VERSION" ]; then

Загрузка…
Отмена
Сохранить