bash shell integration: Dont call _ksi_prompt_command from PROMPT_COMMAND unlessit is set

This commit is contained in:
Kovid Goyal 2022-02-08 19:41:04 +05:30
parent c9da734c0e
commit 7457f637a2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -136,14 +136,15 @@ _ksi_main() {
# install our prompt command, using an array if it is unset or already an array, # install our prompt command, using an array if it is unset or already an array,
# otherwise append a string # otherwise append a string
builtin local pc='builtin declare -F _ksi_prompt_command > /dev/null 2> /dev/null && _ksi_prompt_command'
if [[ -z "${PROMPT_COMMAND}" ]]; then if [[ -z "${PROMPT_COMMAND}" ]]; then
PROMPT_COMMAND=([0]="_ksi_prompt_command") PROMPT_COMMAND=([0]="$pc")
elif [[ $(builtin declare -p PROMPT_COMMAND 2> /dev/null) =~ 'declare -a PROMPT_COMMAND' ]]; then elif [[ $(builtin declare -p PROMPT_COMMAND 2> /dev/null) =~ 'declare -a PROMPT_COMMAND' ]]; then
PROMPT_COMMAND+=("_ksi_prompt_command") PROMPT_COMMAND+=("$pc")
else else
PROMPT_COMMAND="${PROMPT_COMMAND%% }" PROMPT_COMMAND="${PROMPT_COMMAND%% }"
PROMPT_COMMAND="${PROMPT_COMMAND%%;}" PROMPT_COMMAND="${PROMPT_COMMAND%%;}"
PROMPT_COMMAND+="; _ksi_prompt_command" PROMPT_COMMAND+="; $pc"
fi fi
} }
_ksi_main _ksi_main