Avoid wrecking pipestatus in Bash (#1141)

This commit is contained in:
Ajeet D'Souza 2025-11-18 06:32:03 +05:30 committed by GitHub
parent fcce9804a7
commit 0c55cb9621
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 3 deletions

View File

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