mirror of
https://github.com/halcyon/asdf-java.git
synced 2024-10-05 23:32:11 +08:00
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.
This commit is contained in:
parent
ac1920f8c3
commit
fb67e8ba4d
@ -15,11 +15,13 @@ function _asdf_java_update_java_home() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _asdf_java_prompt_command() {
|
function _asdf_java_prompt_command() {
|
||||||
|
local e=$?
|
||||||
if [[ "${PWD}" == "${LAST_PWD}" ]]; then
|
if [[ "${PWD}" == "${LAST_PWD}" ]]; then
|
||||||
return
|
return $e
|
||||||
fi
|
fi
|
||||||
LAST_PWD="${PWD}"
|
LAST_PWD="${PWD}"
|
||||||
_asdf_java_update_java_home
|
_asdf_java_update_java_home
|
||||||
|
return $e
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! [[ "${PROMPT_COMMAND:-}" =~ _asdf_java_prompt_command ]]; then
|
if ! [[ "${PROMPT_COMMAND:-}" =~ _asdf_java_prompt_command ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user