bug-readline
[Top][All Lists]
Advanced

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

rl_startup_hook is called before readline prints every prompt


From: 林宏雄
Subject: rl_startup_hook is called before readline prints every prompt
Date: Wed, 13 Dec 2023 00:18:08 +0900

The version number and release status of Readline (e.g., 4.2-release)

commit bfe9c573a9e376323929c80b2b71c59727fab0cc (HEAD -> master, origin/master, origin/HEAD)
Author: Chet Ramey <chet.ramey@case.edu>
Date:   Fri Nov 17 16:06:49 2023 -0500

a description of the bug

From: https://tiswww.cwru.edu/php/chet/readline/readline.html#index-rl_005fstartup_005fhook

> Variable: rl_hook_func_t * rl_startup_hook
> If non-zero, this is the address of a function to call just before readline prints the first prompt.

rl_startup_hook is called before readline prints every prompt.

a recipe for recreating the bug reliably

--- rl.c ----
#include <stdlib.h>
#include <stdio.h>
#include <readline/readline.h>

static int
startup () {
  printf("startup\n");
  return 0;
}

int
main (int c, char **v)
{
  char *temp;
  rl_startup_hook = startup;

  while ((temp = readline ("> ")) != 0) {
    printf ("%s\n", temp);
  }
  exit (0);
}
----
$ ./rl
startup
> foo
foo
startup
> bar
bar
startup
...

a fix for the bug if you have one!

add a flag variable to check the first call.
--
Hiroo Hayashi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]