From 96269510d3891932c467b018cd27c327acfd8b06 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 14 Jan 2022 23:26:40 +0530 Subject: [PATCH] Abort before defining anything and dont touch global state via set --- shell-integration/bash/kitty.bash | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/shell-integration/bash/kitty.bash b/shell-integration/bash/kitty.bash index 97e7c2443..3a24b6edb 100644 --- a/shell-integration/bash/kitty.bash +++ b/shell-integration/bash/kitty.bash @@ -1,22 +1,20 @@ #!/bin/bash +if [[ $- != *i* ]] ; then builtin return; fi # check in interactive mode +if [[ -z "$KITTY_SHELL_INTEGRATION" ]]; then builtin return; fi + # this is defined outside _ksi_main to make it global without using declare -g # which is not available on older bash builtin declare -A _ksi_prompt _ksi_prompt=( [cursor]='y' [title]='y' [mark]='y' [complete]='y' [ps0]='' [ps1]='' [ps2]='' ) _ksi_main() { - if [[ $- != *i* ]] ; then builtin return; fi # check in interactive mode - if [[ -z "$KITTY_SHELL_INTEGRATION" ]]; then builtin return; fi - builtin set -f for i in ${KITTY_SHELL_INTEGRATION[@]}; do - builtin set +f if [[ "$i" == "no-cursor" ]]; then _ksi_prompt[cursor]='n'; fi if [[ "$i" == "no-title" ]]; then _ksi_prompt[title]='n'; fi if [[ "$i" == "no-prompt-mark" ]]; then _ksi_prompt[mark]='n'; fi if [[ "$i" == "no-complete" ]]; then _ksi_prompt[complete]='n'; fi done - builtin set +f builtin unset KITTY_SHELL_INTEGRATION