bug-readline
[Top][All Lists]
Advanced

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

Re: [Bug-readline] readline-5.1+ has inconsistent echo behavior


From: Chet Ramey
Subject: Re: [Bug-readline] readline-5.1+ has inconsistent echo behavior
Date: Thu, 28 Feb 2008 16:58:12 -0500
User-agent: Thunderbird 2.0.0.12 (Macintosh/20080213)

Mike Frysinger wrote:
starting with readline-5.1, the echo behavior from stdin seems to be inconsistent. the simple test case:
$ cat readline-test.c
#include <stdio.h>
#include <readline/readline.h>
int main() { readline(NULL); }
$ gcc readline-test.c -lreadline -o readline-test
$ echo test > test
$ cat test | ./readline-test
$ ./readline-test < test
test

shouldnt the behavior be the same whether the file is being piped or redirected ?

This behavior differs between systems.  Readline will turn on echoing if
the terminal settings indicate it's already on, or if it can detect there's
no terminal (since there's no tty to do the echoing).  It uses the errno
value set when tcgetattr() returns -1 to detect that the standard input's
not a terminal.

Posix specifies that tcgetattr() sets errno to ENOTTY when the fd it
uses is not a terminal.  Linux sets it to EINVAL when the standard
input is a pipe and ENOTTY when the standard input is redirected from a
file.  Readline only checks for ENOTTY.

So readline needs to check for EINVAL and turn on echoing in that case.
The next version of readline will do so.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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