-----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             [EMAIL PROTECTED]
-----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-----


_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to