Re: Fwd: read -t 0 fails to detect input.

2019-12-20 Thread Chet Ramey
On 12/19/19 3:07 PM, Bize Ma wrote: > To: Chester Ramey > > On thu., dec. 19 of 2019 at 12:40, Chet Ramey () wrote: > >> On 12/18/19 6:40 PM, Bize Ma wrote: >> > > > The exit status is 0 if input is available on the specified file >>> descriptor, non-zero otherwise. >> >> Bash-5.0 uses s

Re: Fwd: read -t 0 fails to detect input.

2019-12-20 Thread Greg Wooledge
On Fri, Dec 20, 2019 at 10:40:26AM -0400, Bize Ma wrote: > I am not the one making those comments. I don't have enough C expertise > to neither confirm or deny them. But that also makes me unable to answer to > the > author of the comments in the proper way. I intended to receive something to > cor

Re: Fwd: read -t 0 fails to detect input.

2019-12-20 Thread Bize Ma
On Fri., 20 dec. 2019 at 3:57, Martin Schulte () wrote: > Hello! > > > Could you please comment about this assertions: > > > > 1.- bash will either do a select() or an ioctl(FIONREAD), or neither > > of them, but not both, as it should for it to work. read -t0 is broken. > > 2.- Conclusion: re

Re: Fwd: read -t 0 fails to detect input.

2019-12-19 Thread Martin Schulte
Hello! > Could you please comment about this assertions: > > 1.- bash will either do a select() or an ioctl(FIONREAD), or neither > of them, but not both, as it should for it to work. read -t0 is broken. > 2.- Conclusion: read -t0 is *broken* in bash. Don't use it. – No. It works as intended

Fwd: read -t 0 fails to detect input.

2019-12-19 Thread Bize Ma
To: Chester Ramey On thu., dec. 19 of 2019 at 12:40, Chet Ramey () wrote: > On 12/18/19 6:40 PM, Bize Ma wrote: > > >>> The exit status is 0 if input is available on the specified file > > descriptor, non-zero otherwise. > > Bash-5.0 uses select/FIONREAD to determine whether or not there is

Re: read -t 0 fails to detect input.

2019-12-19 Thread Chet Ramey
On 12/18/19 6:40 PM, Bize Ma wrote: It seems that read -t 0 should detect if there is input from a pipe (and others). From man bash: If timeout is 0, read returns immediately, without trying to read any data. The exit status is 0 if input is available on the specified file descriptor, n

Re: read -t 0 fails to detect input.

2019-12-18 Thread Robert Elz
Date:Wed, 18 Dec 2019 19:40:45 -0400 From:Bize Ma Message-ID: | A little delay seems to get it working: | | $ echo value | { read -t 0 var; } ; echo $? | 0 It might, but that is adding no significant delay, and the results are unpredictable. jinx$ echo val

read -t 0 fails to detect input.

2019-12-18 Thread Bize Ma
It seems that read -t 0 should detect if there is input from a pipe (and others). >From man bash: >> If timeout is 0, read returns immediately, without trying to read any data. >> The exit status is 0 if input is available on the specified file descriptor, non-zero otherwise. So, it seems that