From 5cb5bbdc32fa581c5e2c93552cf60a9ded4d147a Mon Sep 17 00:00:00 2001 From: Christoph Anton Mitterer Date: Sun, 24 Sep 2023 22:55:31 +0200 Subject: [PATCH 1/3] [fish] exit as well when called from non-interactive shell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just like with the other shells, exit fish to, if called from a non-interactive shell. We use an `if`-block and don’t just return immediately for now, as older versions of fish (namely < 3.4.0) did not support to use `return` in `.`-scripts (this was only added with fish commit 3359e5d2e9bcbf19d1652636c8e448a6889302ae). Just using `exit` instead of a `return` wouldn’t be a proper solution either, as it would exit the whole shell, when `shell/key-bindings.fish` was executed or sourced from a non-interactive shell. While this should of course never happen, the idea of the whole check is to handle the situation gracefully, which `exit` can thus not do. Signed-off-by: Christoph Anton Mitterer --- shell/key-bindings.fish | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index abaefead0ef..5cc9d0b3a9d 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -11,6 +11,9 @@ # - $FZF_ALT_C_COMMAND # - $FZF_ALT_C_OPTS +if status is-interactive + + # Key bindings # ------------ function fzf_key_bindings @@ -170,3 +173,6 @@ function fzf_key_bindings end end + + +end From 376308de9a6dcdbe63e3370e6083d76129925113 Mon Sep 17 00:00:00 2001 From: Christoph Anton Mitterer Date: Mon, 11 Oct 2027 20:41:10 +0200 Subject: [PATCH 2/3] [fish] drop interactiveness-checks support for fish versions < 3.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This improves commit 5cb5bbdc32fa581c5e2c93552cf60a9ded4d147a by just returning from the script in case it’s sourced from a non-interactive shell, rather then using an `if`-block to not execute any further code (which is error prone, in case code gets accidentally added outside the `if`, and also less readable). This removes support for fish versions < 3.4.0, which should now no longer be used. Signed-off-by: Christoph Anton Mitterer --- shell/key-bindings.fish | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index 5cc9d0b3a9d..2dc3789be2b 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -11,7 +11,7 @@ # - $FZF_ALT_C_COMMAND # - $FZF_ALT_C_OPTS -if status is-interactive +status is-interactive; or return 0 # Key bindings @@ -173,6 +173,3 @@ function fzf_key_bindings end end - - -end From ce0e3965cc3159d7c00f72cab1eb7fe30321fcba Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 12 Oct 2023 20:58:17 +0900 Subject: [PATCH 3/3] Update shell/key-bindings.fish --- shell/key-bindings.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index 2dc3789be2b..bbe33e54ec6 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -11,7 +11,7 @@ # - $FZF_ALT_C_COMMAND # - $FZF_ALT_C_OPTS -status is-interactive; or return 0 +status is-interactive; or exit # Key bindings