mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-09-19 12:08:07 +00:00
bash: detect hooks in prompt command arrays (#14266)
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.
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user