bug-coreutils
[Top][All Lists]
Advanced

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

bug in yesno()?


From: Eric Blake
Subject: bug in yesno()?
Date: Fri, 17 Feb 2006 18:01:09 -0700
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

For several utilities, POSIX requires that the utility "shall write a
prompt to the standard error and read a line from the standard input".  I
was trying to take advantage of this wording to test my patch for 'rm -I'
to make sure only one line is consumed.  However, I discovered that
yesno() uses standard input in a buffered mode, such that rm is consuming
an entire buffer's worth of data from the stdin pipe, and discarding
everything after the first line, such that the followon cat sees an empty
pipe.  Compare that to the bash read builtin, which also reads a line from
stdin, but does not consume the remaining data in the pipe:

$ echo 'n
y' | (rm -i file 2>/dev/null; cat)
$ echo 'n
y' | (read a; cat)
y
$

Should yesno() be setting the properties of stdin to be unbuffered for the
duration of the getline(), so that the rest of stdin is not consumed too
early?

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFD9nHV84KuGfSFAYARAq2EAJ0Z1lWNSRFRff9TLowxvZrQyjo4VgCgtORo
9l39Kuk5e6O5FT3FwMdHlQA=
=GDgd
-----END PGP SIGNATURE-----




reply via email to

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