On Sat, Sep 6, 2025 at 11:35 PM Grisha Levit <[email protected]> wrote:
>
> If a macro is invoked while a keyboard macro is being defined, avoid
> having the newly defined macro contain both the key sequence invoking
> the macro and the value of the invoked macro.
The approach in the patch above makes it so that if a bound macro tries
to define a keyboard macro, the resulting macro will be empty. If this
is the first keyboard macro definition attempt, this will segfault:
INPUTRC=<(echo '"A": "\C-x(-\C-x)"') bash-asan --norc -in <<< $'A'
macro.c:281:3: runtime error: applying zero offset to null pointer
Disallowing keyboard macro definition from a bound macro addresses this
but if this is a useful feature then this may be the wrong approach.
---
lib/readline/macro.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/readline/macro.c b/lib/readline/macro.c
index 9ac258d5..f45ff26f 100644
--- a/lib/readline/macro.c
+++ b/lib/readline/macro.c
@@ -245,7 +245,7 @@ _rl_kill_kbd_macro (void)
int
rl_start_kbd_macro (int ignore1, int ignore2)
{
- if (RL_ISSTATE (RL_STATE_MACRODEF))
+ if (RL_ISSTATE (RL_STATE_MACRODEF|RL_STATE_MACROINPUT))
{
_rl_abort_internal ();
return 1;
--
2.50.1