On 12/18/2011 09: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.
http://austingroupbugs.net/view.php?id=367 POSIX made a change to require the following on read: An error in setting any variable (such as if a var has previously been marked readonly) shall be considered an error of read processing, and shall result in a return value greater than one. At line 103977 [XCU read EXIT STATUS], change >0 End-of-file was detected or an error occurred. to 1 End-of-file was detected. >1 An error occurred. Getting a timeout or invalid file descriptor should definitely be considered error cases that return > 1 (SIGALRM for timeout works well). -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature