On 8/27/14, 3:20 PM, Stephane Chazelas wrote: > However, one could imagine using bash's read to get data off a > tty device not in canonical mode (a serial device used as just a > serial device), or any other non-terminal character device for > that matter (a "strace bash -c 'read < /dev/urandom'" reveals > there's an issue there as well), and that would be more of a > problem. > > Again, not a big one (hence the [minor] tag) but still a > non-POSIX conformance and bash seems to be the only shell with > the problem (though ksh93 has its own bugs as usual).
Well, again you have to rely on the system telling you what's happening. Bash tests whether a file descriptor is seekable using, logically enough, lseek. If it doesn't return -1/ESPIPE, bash assumes the fd is seekable. If it does, bash does unbuffered reads. (If isatty() returns true, bash does assume that read(2) will return newline-delimited records.) Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/