From e1b08619bbc0f4249271fc66c4049973b256b58d Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Thu, 1 Sep 2022 19:04:22 +0900 Subject: [PATCH 1/4] fix readline signal setups after trap INT in compfunc --- eval.c | 8 ++++++++ pcomplete.c | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/eval.c b/eval.c index 17fbf736..c0b45079 100644 --- a/eval.c +++ b/eval.c @@ -48,6 +48,10 @@ # include "bashhist.h" #endif +#if defined (READLINE) +# include +#endif + static void send_pwd_to_eterm PARAMS((void)); static sighandler alrm_catcher PARAMS((int)); @@ -119,6 +123,10 @@ reader_loop () current_command = (COMMAND *)NULL; } +#if defined (READLINE) + if (interactive_shell) + rl_clear_signals (); +#endif restore_sigmask (); break; diff --git a/pcomplete.c b/pcomplete.c index 9612406d..f7b2811c 100644 --- a/pcomplete.c +++ b/pcomplete.c @@ -1123,6 +1123,12 @@ gen_shell_function_matches (cs, cmd, text, line, ind, lwords, nw, cw, foundp) #if defined (ARRAY_VARS) ARRAY *a; #endif + /* XXX - Are there any robust way to test if it is directly invoked for the + programmable completions but not for the compgen builtin (called directly + by users or called while the programmable completions inside another -F)? + Maybe, we can add another parameter, such as FLAGS, to this function and + `gen_compspec_completions ()'? */ + int performed_for_programmable_completions = lwords != NULL; found = 0; if (foundp) @@ -1151,6 +1157,11 @@ gen_shell_function_matches (cs, cmd, text, line, ind, lwords, nw, cw, foundp) pps = &ps; save_parser_state (pps); begin_unwind_frame ("gen-shell-function-matches"); + if (performed_for_programmable_completions) + { + rl_clear_signals (); + add_unwind_protect (rl_set_signals, (char *)NULL); + } add_unwind_protect (restore_parser_state, (char *)pps); add_unwind_protect (dispose_words, (char *)cmdlist); add_unwind_protect (unbind_compfunc_variables, (char *)0); @@ -1158,6 +1169,8 @@ gen_shell_function_matches (cs, cmd, text, line, ind, lwords, nw, cw, foundp) fval = execute_shell_function (f, cmdlist); discard_unwind_frame ("gen-shell-function-matches"); + if (performed_for_programmable_completions) + rl_set_signals (); restore_parser_state (pps); found = fval != EX_NOTFOUND; -- 2.37.2