Merge pull request #2540 from ianchen-tw/detect-shell

Export detected shell environment in pyenv-init
This commit is contained in:
Anton Petrov 2022-12-02 18:07:11 +03:00 committed by GitHub
commit 58bbbf8880
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Summary: Configure the shell environment for pyenv # Summary: Configure the shell environment for pyenv
# Usage: eval "$(pyenv init [-|--path] [--no-push-path] [--no-rehash] [<shell>])" # Usage: eval "$(pyenv init [-|--path] [--no-push-path] [--detect-shell] [--no-rehash] [<shell>])"
set -e set -e
[ -n "$PYENV_DEBUG" ] && set -x [ -n "$PYENV_DEBUG" ] && set -x
@ -11,6 +11,7 @@ if [ "$1" = "--complete" ]; then
echo --path echo --path
echo --no-push-path echo --no-push-path
echo --no-rehash echo --no-rehash
echo --detect-shell
echo bash echo bash
echo fish echo fish
echo ksh echo ksh
@ -33,6 +34,11 @@ do
shift shift
fi fi
if [ "$args" = "--detect-shell" ]; then
mode="detect-shell"
shift
fi
if [ "$args" = "--no-push-path" ]; then if [ "$args" = "--no-push-path" ]; then
no_push_path=1 no_push_path=1
shift shift
@ -76,12 +82,17 @@ function main() {
print_shell_function print_shell_function
exit 0 exit 0
;; ;;
"detect-shell")
detect_profile
print_detect_shell
exit 0
;;
esac esac
# should never get here # should never get here
exit 2 exit 2
} }
function help_() { function detect_profile() {
case "$shell" in case "$shell" in
bash ) bash )
if [ -e '~/.bash_profile' ]; then if [ -e '~/.bash_profile' ]; then
@ -105,7 +116,16 @@ function help_() {
rc='your shell'\''s interactive startup file' rc='your shell'\''s interactive startup file'
;; ;;
esac esac
}
function print_detect_shell() {
echo "PYENV_SHELL_DETECT=$shell"
echo "PYENV_PROFILE_DETECT=$profile"
echo "PYENV_RC_DETECT=$rc"
}
function help_() {
detect_profile
{ {
case "$shell" in case "$shell" in
fish ) fish )