bug-bash
[Top][All Lists]
Advanced

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

Re: "read" builtin: timeout vs. EOF


From: Chet Ramey
Subject: Re: "read" builtin: timeout vs. EOF
Date: Mon, 19 Dec 2011 09:28:43 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 12/18/11 11:45 AM, Stephen Gildea wrote:
> The "read" built-in documentation says,
> 
>     Exit Status:
>     The return code is zero, unless end-of-file is encountered, read times 
> out,
>     or an invalid file descriptor is supplied as the argument to -u.
> 
> I would like to be able to distinguish the no-data conditions.  In
> particular I want to know whether I got a timeout or an end-of-file,
> but as you can see, Bash is not documented to behave differently in
> these two cases.
> 
> As it happens, in Bash 4.2, "read" exits with status 1 on EOF and
> SIGALRM on timeout.  This is just what I want.  Can I count on this
> behavior?  If so, please commit to it with documentation.

Sure.  It seems reasonable that if the read builtin `exits' due to a
signal, it should set the exit status the same way as any other command
that exits that way (128+SIGALRM).  The documentation already says
"the exit status is greater than 128 if the timeout is exceeded" in a
couple of places.  Does it really need to be in the help text, which is
just a short reminder reference, as well?

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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