[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: performance of shell read loops
On Sat, Mar 12, 2016 at 10:17:26PM +0700, Robert Elz wrote:
> | Actually I was wondering if there aren't more use cases for a "read
> | until you find the following sequence" system call or just something
> | specifiying a (simple) regular expression.
> I was too - but I suspect that the only users that matter would want \n
> as the terminator (or EOF of course) - other stuff (vi input mode that
> can end on ESC) don't do enough input for it to be worth the bother. So
> I suspect that just line mode buffering (like ttys do, and like is available
> on output via stdio) would probably be enough for 90% of uses, or more.
> More complexity just makes it harder to use, and more likely to be full of
All too true ...
> "Line mode input" could be a simple fcntl flag.
To speed up the shell you'd really need it to be a property of the read
not the open file.
Otherwise the shell would have to turn it off and on between reads.
(Although 3 system calls per line would be better than one per character.)
Specific shell scripts could be sped up with a shell option to do
locally buffered reads (auto-cleared when stdin redirected).
That puts the onus on the script writer to decide when it is valid.
David Laight: david%l8s.co.uk@localhost
Main Index |
Thread Index |