From 0f7b8fa8eebed0379b2672e44ffceb22a19dd541 Mon Sep 17 00:00:00 2001 From: native-api Date: Fri, 5 Dec 2025 20:42:25 +0300 Subject: [PATCH] sh-rehash: Fix erroneously executing rather than printing a command (#3369) --- libexec/pyenv-sh-rehash | 2 +- test/rehash.bats | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libexec/pyenv-sh-rehash b/libexec/pyenv-sh-rehash index ab50346d..470eda07 100755 --- a/libexec/pyenv-sh-rehash +++ b/libexec/pyenv-sh-rehash @@ -11,7 +11,7 @@ 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. -pyenv-rehash +echo "pyenv-rehash" case "$shell" in fish ) diff --git a/test/rehash.bats b/test/rehash.bats index 8afe87e6..5505a7d8 100755 --- a/test/rehash.bats +++ b/test/rehash.bats @@ -110,13 +110,27 @@ SH @test "sh-rehash in bash" { create_executable "3.4" "python" PYENV_SHELL=bash run pyenv-sh-rehash - assert_success "hash -r 2>/dev/null || true" + assert_success "pyenv-rehash +hash -r 2>/dev/null || true" +} + +@test "sh-rehash in bash (integration)" { + create_executable "3.4" "python" + run eval "$(pyenv-sh-rehash)" + assert_success assert [ -x "${PYENV_ROOT}/shims/python" ] } @test "sh-rehash in fish" { create_executable "3.4" "python" PYENV_SHELL=fish run pyenv-sh-rehash - assert_success "" + assert_success "pyenv-rehash" +} + +@test "sh-rehash in fish (integration)" { + command -v fish >/dev/null || skip "-- fish not installed" + create_executable "3.4" "python" + run fish -Nc "eval (pyenv-sh-rehash)" + assert_success assert [ -x "${PYENV_ROOT}/shims/python" ] }