Subject: Re: sh reads byte by byte
To: David Laight <email@example.com>
From: Thor Lancelot Simon <firstname.lastname@example.org>
Date: 01/20/2007 17:09:41
On Sat, Jan 20, 2007 at 07:45:35PM +0000, David Laight wrote:
> Not easily, the problem is that it has to leave the fd positioned to the
> correct byte after each 'read' - since it might fork/exec some other
> process that reads from the same fd, and will expect to get the byte
> following the newline.
It seems like it might be possible to detect when this can't happen, and
read in longer chunks -- but that is probably hard.
> If the shell could determine whether the input file was seekable, it could
> do a longer read and reposition afterwards.
Can't it try a seek, and fall back to the current strategy if it fails?