Subject: Re: sh reads byte by byte
To: NetBSD User-Level Technical Discussion List <tech-userlevel@NetBSD.org>
From: Manuel Bouyer <firstname.lastname@example.org>
Date: 02/23/2007 14:36:29
On Wed, Feb 21, 2007 at 06:24:57PM -0500, Greg A. Woods wrote:
> 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.
Maybe this could be rewritten in awk; I'm not familiar with awk enough to
do it, or even decide if it's a good idea. If I had to rewrite it I would
do it in perl :)
Manuel Bouyer, LIP6, Universite Paris VI. Manuel.Bouyer@lip6.fr
NetBSD: 26 ans d'experience feront toujours la difference