Fix non-bash output while detecting shell (#2561)

Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
This commit is contained in:
Ian Chen 2022-12-25 07:35:03 +08:00 committed by GitHub
parent 773c65416b
commit f897c50202
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View file

@ -83,7 +83,7 @@ function main() {
exit 0 exit 0
;; ;;
"detect-shell") "detect-shell")
detect_profile detect_profile 1
print_detect_shell print_detect_shell
exit 0 exit 0
;; ;;
@ -93,6 +93,8 @@ function main() {
} }
function detect_profile() { function detect_profile() {
local detect_for_detect_shell="$1"
case "$shell" in case "$shell" in
bash ) bash )
if [ -e '~/.bash_profile' ]; then if [ -e '~/.bash_profile' ]; then
@ -112,8 +114,13 @@ function detect_profile() {
rc='~/.profile' rc='~/.profile'
;; ;;
* ) * )
if [ -n "$detect_for_detect_shell" ]; then
profile=
rc=
else
profile='your shell'\''s login startup file' profile='your shell'\''s login startup file'
rc='your shell'\''s interactive startup file' rc='your shell'\''s interactive startup file'
fi
;; ;;
esac esac
} }

View file

@ -63,6 +63,12 @@ OUT
assert_line 'pyenv init - | source' assert_line 'pyenv init - | source'
} }
@test "shell detection for installer" {
run pyenv-init --detect-shell
assert_success
assert_line "PYENV_SHELL_DETECT=bash"
}
@test "option to skip rehash" { @test "option to skip rehash" {
run pyenv-init - --no-rehash run pyenv-init - --no-rehash
assert_success assert_success