From d0b403304d26e642a3f86d52aba2c9ee96e85671 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Sun, 8 Feb 2026 09:40:05 -0500 Subject: [PATCH] bash: use PROMPT_COMMAND array form in bash 5.1+ PROMPT_COMMAND array support for introduced in bash 5.1, and it's the preferred format moving forward. Using the string form is also fine, but it's easy to be a modern bash citizen here, so let's do so. --- src/shell-integration/bash/ghostty.bash | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/shell-integration/bash/ghostty.bash b/src/shell-integration/bash/ghostty.bash index cb3bd6bdd..65a49a190 100644 --- a/src/shell-integration/bash/ghostty.bash +++ b/src/shell-integration/bash/ghostty.bash @@ -284,7 +284,12 @@ if (( BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 4) ) # Append our hook to PROMPT_COMMAND, preserving its existing type. if [[ ";${PROMPT_COMMAND[*]:-};" != *";__ghostty_hook;"* ]]; then if [[ -z "${PROMPT_COMMAND[*]}" ]]; then - PROMPT_COMMAND="__ghostty_hook" + if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then + PROMPT_COMMAND=(__ghostty_hook) + else + # shellcheck disable=SC2178 + PROMPT_COMMAND="__ghostty_hook" + fi elif [[ $(builtin declare -p PROMPT_COMMAND 2>/dev/null) == "declare -a "* ]]; then PROMPT_COMMAND+=(__ghostty_hook) else