Subject: Re: sh reads byte by byte
To: Manuel Bouyer <bouyer@antioche.eu.org>
From: Greg A. Woods <woods@weird.com>
List: tech-userlevel
Date: 02/21/2007 18:24:57
At Sat, 20 Jan 2007 17:01:08 +0100,
Manuel Bouyer wrote:
> 
> while trying to see how to speedup audit-packages as used by the bulk builds,
> I noticed (using ktrace) that something like this:
> #!/bin/sh
> 
> while read a b c; do
> echo $a $b $c
> done < /tmp/file
> 
> will read /tmp/file byte by byte. With the current pkg-vulnerabilities
> this makes 221909 syscalls. Would there be a way to have it read the
> file in a more efficient way (rewriting it in another language is not an
> option for now) ?

Why not rewrite?  That would seem to be the correct solution.  Can't
AWK, for example, do the job?

If you're talking specifically about the "while read pat type url; do"
loop in audit-packages, then that would indeed seem to be an ideal
application for AWK.

-- 
						Greg A. Woods

H:+1 416 218-0098 W:+1 416 489-5852 x122 VE3TCP RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>       Secrets of the Weird <woods@weird.com>