bug-bash
[Top][All Lists]
Advanced

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

Re: Problem with line buffered IO when no tty


From: Steven W. Orr
Subject: Re: Problem with line buffered IO when no tty
Date: Thu, 07 Jul 2011 09:24:37 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11

On 7/7/2011 9:21 AM, Eric Blake wrote:
On 07/07/2011 06:55 AM, Steven W. Orr wrote:
So, why is it that bash is behaving like it is always line buffered or
unbuffered, even if there is no console?

Because POSIX requires 'sh' to behave like it is unbuffered:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html

When the shell is using standard input and it invokes a command that
also uses standard input, the shell shall ensure that the standard input
file pointer points directly after the command it has read when the
command begins execution. It shall not read ahead in such a manner that
any characters intended to be read by the invoked command are consumed
by the shell (whether interpreted by the shell or not) or that
characters that are not read by the invoked command are not seen by the
shell.

Bash meets this requirement by reading one byte at a time on
non-seekable input, rather than relying on the decision of libc on
whether stdin defaults to fully-buffered or line-buffered.


Thank you! That's what I was looking for. :-)

--
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



reply via email to

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