When readline is called to get user input, it is called without
a prompt argument. As a result, if the user does not enter anything
for a given field, then the next field is displayed on the same
line, yielding the following output:
$ chfn
Changing finger information for user.
Password:
Name []: Office []: Office Phone []: Home Phone []:
instead of the expected:
$ chfn
Changing finger information for user.
Password:
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
This patch restores the expected behavior by feeding readline with
a character to display as "prompt".
[kzak@redhat.com: - do the same change in chsh
- use ' ' rather than '\n' for non-readline code]
Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
if (!def_val)
def_val = "";
while (true) {
- printf("%s [%s]: ", question, def_val);
+ printf("%s [%s]:", question, def_val);
__fpurge(stdin);
#ifdef HAVE_LIBREADLINE
rl_bind_key('\t', rl_insert);
- if ((buf = readline(NULL)) == NULL)
+ if ((buf = readline(" ")) == NULL)
#else
+ putchar(' ');
if (getline(&buf, &dummy, stdin) < 0)
#endif
errx(EXIT_FAILURE, _("Aborted."));
#endif
if (!oldshell)
oldshell = "";
- printf("%s [%s]\n", question, oldshell);
+ printf("%s [%s]:", question, oldshell);
#ifdef HAVE_LIBREADLINE
- if ((ans = readline("> ")) == NULL)
+ if ((ans = readline(" ")) == NULL)
#else
+ putchar(' ');
if (getline(&ans, &dummy, stdin) < 0)
#endif
return NULL;