Re: client: set rl_prompt after saving
Justin Bronder <[email protected]> Mon, 20 Oct 2025 13:44:24 -0400
| Newsgroups | dev.linux.lists.connman |
|---|---|
| Message-ID | <[email protected]> |
On 20/10/25 08:07 +0000, Thomas Bartosik wrote:
> ||Shouldn't rl_set_prompt("") be called first as stated in your intro
> (and the link referenced)?
As I understand it, rl_save_prompt() sets rl_prompt to NULL and we need to set it to something after that (by using rl_set_prompt()) prior to rl_redisplay() being called.
>
> I only see __connmanctl_agent_mode setting the prompt as well, so if this
> function is not called before, there's still a save without a set before?
>
> On 18.10.25 23:24, Justin Bronder wrote:
> > Readline 8.3 crashes when rl_save_prompt() is called without
> > rl_set_prompt() being called first [1]. This means that interactive
> > connmanctl immediately crashes upon invocation. As we're about to clear
> > the line anyways, we can just set the buffer to an empty string as well.
> >
> > Alternatively, I believe that both rl_set_prompt() and rl_replace_line()
> > could be replaced by a call to rl_message("") but I don't want to
> > expand the scope of this patch.
> >
> > 1. https://lists.gnu.org/archive/html/bug-readline/2025-07/msg00007.html
> >
> > Signed-off-by: Justin Bronder <[email protected]>
> > ---
> > client/input.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/client/input.c b/client/input.c
> > index 78319ff8..27c281d1 100644
> > --- a/client/input.c
> > +++ b/client/input.c
> > @@ -62,6 +62,7 @@ void __connmanctl_save_rl(void)
> > saved_point = rl_point;
> > saved_line = rl_copy_text(0, rl_end);
> > rl_save_prompt();
> > + rl_set_prompt("");
> > rl_replace_line("", 0);
> > rl_redisplay();
> > }
>
>
--
Justin Bronder