Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: stream buffering



On Fri, 18 Feb 2011, Peter Stephenson wrote:

> On Thu, 17 Feb 2011 19:40:20 -0600 (CST)
> Rory Mulvaney <rorymulv@xxxxxxxxx> wrote:
> 
> > I'm wondering if the reason that some I/O intensive zsh shell scripts 
> > aren't fast is mostly only because the I/O is (I think) line-buffered. 
> > Is there a way to do full buffering of streams, or what would be the 
> > best way to provide it?  Maybe a module similar to zsh/net/socket, 
> > perhaps using setvbuf(3)?
> 
> What I/O are you referring to?  The shell's own input for a script needs 
> to be parsed and intepreted, which will be much more of a restriction than 
> buffering except for scripts with really silly amounts of embedded text 
> like here documents.  Standard input to the shell via the read builtin 
> etc. similarly tends to be in short chunks, likewise output via print.  
> Input to other commands run from scripts makes its own arrangements for 
> buffering.

Sorry, I'm definitely referring to the type of I/O using read and print 
(or some other builtin created by a module).  And I don't necessarily mean 
in a script; it could just be from a loop on the command line where the 
loop reads or prints all lines in a file.

while read var ; do 
  -something- 
done

-Rory 

[sorry if there are some incorrect threading headers, since I just 
subscribed now]



Messages sorted by: Reverse Date, Date, Thread, Author