From a4031c8e3f94f40df712de7cdf6fd4f6c17980c6 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Tue, 15 Sep 2026 21:29:06 -0400 Subject: [PATCH] bash: detect hooks in prompt command arrays The delimiter-based guard treats PROMPT_COMMAND as a semicolon-separated command list. Indexed array expansion joins elements with spaces instead, so a hook appended after an existing element is not detected when the integration is sourced again. Match the full internal hook command as a substring so the guard works for both scalar and array values. This intentionally gives up command boundary matching; the private function name and redirection keep an incidental match unlikely. --- src/shell-integration/bash/ghostty.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shell-integration/bash/ghostty.bash b/src/shell-integration/bash/ghostty.bash index 76e7cc71b..101f750ce 100644 --- a/src/shell-integration/bash/ghostty.bash +++ b/src/shell-integration/bash/ghostty.bash @@ -256,7 +256,7 @@ if (( BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 4) ) # errors from inside our hooks, but those are all terminal escape sequences # and non-actionable. # shellcheck disable=SC2128,SC2178,SC2179 - if [[ ";${PROMPT_COMMAND[*]:-};" != *";__ghostty_hook 2>/dev/null;"* ]]; then + if [[ "${PROMPT_COMMAND[*]:-}" != *"__ghostty_hook 2>/dev/null"* ]]; then if [[ -z "${PROMPT_COMMAND[*]}" ]]; then if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then PROMPT_COMMAND=("__ghostty_hook 2>/dev/null")