From fb67e8ba4df61a28e6942650904e3b1a219b1941 Mon Sep 17 00:00:00 2001 From: Jens Broekens Date: Wed, 17 May 2023 06:20:19 +0200 Subject: [PATCH] Return with previous exit code in Bash prompt function (#199) asdf-java prepends to `$PROMPT_COMMAND`, thus swallowing up the previous command's exit code (normally the command the user invoked). This is troublesome if the exit code is used in the user's own prompt command, for example to output a different prompt. --- set-java-home.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/set-java-home.bash b/set-java-home.bash index 6a51a2f..05981d6 100644 --- a/set-java-home.bash +++ b/set-java-home.bash @@ -15,11 +15,13 @@ function _asdf_java_update_java_home() { } function _asdf_java_prompt_command() { + local e=$? if [[ "${PWD}" == "${LAST_PWD}" ]]; then - return + return $e fi LAST_PWD="${PWD}" _asdf_java_update_java_home + return $e } if ! [[ "${PROMPT_COMMAND:-}" =~ _asdf_java_prompt_command ]]; then