Don't downcast PROMPT_COMMAND (#1036)

This commit is contained in:
Sandro 2025-11-02 00:13:18 +01:00 committed by GitHub
parent af220b11e7
commit 5fde31383f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -55,7 +55,12 @@ function __zoxide_hook() {
# Initialize hook.
if [[ ${PROMPT_COMMAND:=} != *'__zoxide_hook'* ]]; then
PROMPT_COMMAND="__zoxide_hook;${PROMPT_COMMAND#;}"
if [[ "$(declare -p PROMPT_COMMAND 2>&1)" == "declare -a"* ]]; then
PROMPT_COMMAND=(__zoxide_hook "${PROMPT_COMMAND[@]}")
else
# shellcheck disable=SC2178
PROMPT_COMMAND="__zoxide_hook;${PROMPT_COMMAND#;}"
fi
fi
{%- endif %}