[EMAIL PROTECTED] wrote:
>     If "read -t" times out without fulfilling a request, any pending data is 
> lost.
> Via strace it's apparent that the problem is that when the user requests a 
> line of
> data, bash read is actually calling read() with a buffer size of one. So bash 
> is 
> holding the data. It's not in the OS file buffer. Then when the timeout 
> occurs,
> bash does not return the read data to the user, or associate it with the file 
> descriptor.

As I read the documentation for bash I see the following:

              -t timeout
                     Cause read to time out and return failure if a
                     complete line of input is not read within timeout
                     seconds.

Therefore if a "complete line of input" has not yet been received when
a timeout occurs it does not matter if data is pending or not.  The
read will return failure.

I believe in the case of a timeout that the current behavior is the
correct thing to do.  The error handling model is simple.  Returning
partial data upon timeout would require a much more complicated error
handling strategy to be implemented by the shell script and all shell
scripts would need to pay that implementation penalty.

Bob


_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to