From a58797c894349fa182665f5dae60daff5baa21c3 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Fri, 16 Feb 2024 17:47:14 +0900 Subject: [PATCH 1/2] Exclude the `bind -x` commands from interactive commands --- bash-preexec.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bash-preexec.sh b/bash-preexec.sh index 5bb11b6..a0124a0 100644 --- a/bash-preexec.sh +++ b/bash-preexec.sh @@ -222,9 +222,9 @@ __bp_preexec_invoke_exec() { return fi - if [[ -n "${COMP_LINE:-}" ]]; then - # We're in the middle of a completer. This obviously can't be - # an interactively issued command. + if [[ -n "${COMP_LINE:-}" || -n "${READLINE_POINT:-}" ]]; then + # We're in the middle of a completer or a keybinding set up by "bind + # -x". This obviously can't be an interactively issued command. return fi if [[ -z "${__bp_preexec_interactive_mode:-}" ]]; then From 96d37dc995ac349d3e1b95c9d516e7a8643c5507 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 17 Feb 2024 07:21:14 +0900 Subject: [PATCH 2/2] Check COMP_POINT instead of possibly empty COMP_LINE The check for COMP_LINE can fail because it can be empty in the completion function for the empty command line "complete -F _func -E". --- bash-preexec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash-preexec.sh b/bash-preexec.sh index a0124a0..641346a 100644 --- a/bash-preexec.sh +++ b/bash-preexec.sh @@ -222,7 +222,7 @@ __bp_preexec_invoke_exec() { return fi - if [[ -n "${COMP_LINE:-}" || -n "${READLINE_POINT:-}" ]]; then + if [[ -n "${COMP_POINT:-}" || -n "${READLINE_POINT:-}" ]]; then # We're in the middle of a completer or a keybinding set up by "bind # -x". This obviously can't be an interactively issued command. return