NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/53352: libedit no longer displaying prompt



>Number:         53352
>Category:       lib
>Synopsis:       libedit no longer displaying prompt
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 07 18:30:00 +0000 2018
>Originator:     Reiner Herrmann
>Release:        
>Organization:
>Environment:
ported libedit on Linux
>Description:
Since libedit/readline.c [v1.145] the prompt is no longer shown after the first finished line, when using rl_callback_handler_install + rl_callback_read_char in an event loop.

[v1.145]: https://github.com/NetBSD/src/commit/11c3569
>How-To-Repeat:
The following program demonstrates the problem.
When entering several lines, the prompt is not displayed after the lines have been handled.


#include <stdio.h>
#include <unistd.h>
#include <sys/select.h>
#include <editline/readline.h>

void readline_handler(char *input)
{
	printf("entered string: %s\n", input);
}

int main()
{
	fd_set rfds;
	FD_ZERO(&rfds);
	FD_SET(STDIN_FILENO, &rfds);

	rl_initialize();
	rl_callback_handler_install("> ", readline_handler);
	
	while(1) {
		if (select(1, &rfds, NULL, NULL, NULL) > 0)
			rl_callback_read_char();
	}

	return 0;
}
>Fix:
Reverting the mentioned commit fixes it for me.
I think the problem is that it checks for rl_already_prompted, which is never set back to 0 after the first input line.
I'm not completely sure what the commit intended to fix, but if rl_already_prompted is changed back to 0 before the callback is called, this would still allow interpreters etc. to set it to 1 if they handle prompts themselves, while keeping the old behavior for the other cases.



Home | Main Index | Thread Index | Old Index