Bug#993153: libedit: rl_startup_hook only executed once. In readline it's executed every readline() call
Carlos Henrique Lima Melara
charlesmelara at outlook.com
Sat Aug 28 04:55:52 BST 2021
Source: libedit
Severity: normal
Tags: upstream
X-Debbugs-Cc: charlesmelara at outlook.com
Dear Maintainer, hi!
I'm porting devtodo to use libedit instead of libreadline and I'm using
the libeditreadline-dev compatibility layer.
Turns out that I need to insert a string in the readline buffer before
the user start to type. This was done via rl_startup_hook, the function
called would rl_insert_text the string and it would go to the buffer and
the screen before the user types.
With the port to libedit, the expected behaviour doesn't occur.
Digging into the readline documentation and source code, as well as
libedit compatibility layer, one thing popped up. In readline, the
rl_startup_hook is executed every time readline is called:
readline_internal_setup():
if (rl_startup_hook)
(*rl_startup_hook) ();
Note: readline_internal_setup() is called by readline().
Though, in libedit, it seems to only be executed in the very first time
readline() is called:
readline():
if (rl_did_startup_hook == 0 && rl_startup_hook) {
rl_did_startup_hook = 1;
(*rl_startup_hook)(NULL, 0);
}
As far as I could debug with gdb, this hipothesis is confirmed. It only
executes rl_startup_hook in the very first readline() call.
I'm here if you need more info, don't hesitate to mail me.
Regards,
Carlos (a.k.a. Charles)
-- System Information:
Debian Release: 11.0
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 5.10.0-8-amd64 (SMP w/8 CPU threads)
Locale: LANG=pt_BR.UTF-8, LC_CTYPE=pt_BR.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
More information about the Pkg-llvm-team
mailing list