Fix bash integration when 'set -o nounset' is in effect

If the user's bash profile contains 'set -u' / 'set -o nounset'
(to protect against typos in variable names; think "rm -Rf $TMp/*"),
starting a new kitty terminal resulted in a
    bash: sourced: unbound variable
message. Also, the error disabled kitty's shell integration.

This PR fixes/supersedes bba4ce22, which was based on an incorrect
assumption.
This commit is contained in:
Matthias Urlichs 2025-09-15 10:36:13 +02:00
parent 4afe56b808
commit 8335b340c9

View file

@ -85,7 +85,7 @@ if [ "${BASH_VERSINFO:-0}" -lt 4 ]; then
builtin return
fi
if [[ "${_ksi_prompt[sourced]}" == "y" ]]; then
if [ -v "_ksi_prompt[sourced]" ]; then
# we have already run
builtin unset KITTY_SHELL_INTEGRATION
builtin return
@ -318,7 +318,7 @@ _ksi_main() {
builtin local venv="${VIRTUAL_ENV}/bin/activate"
builtin local sourced=""
_ksi_s_is_ok() {
[[ -z "${sourced:-}" && "$KITTY_CLONE_SOURCE_STRATEGIES" == *",$1,"* ]] && builtin return 0
[[ -z "$sourced" && "$KITTY_CLONE_SOURCE_STRATEGIES" == *",$1,"* ]] && builtin return 0
builtin return 1
}