> The general idea here is that forking a new process is not usually
> (ever?) the bottleneck, if you have a script that needs to run faster,
> there's other overhead to trim first, and if you really need to, you can:
> (giving up line at a time response).
> 
> ifs=($nl)
> lines=`{cat}
> for($lines as $line){...}

i hate to be pedantic, but i see 2 syntax errors, a
unintended side effect and an extra set of parens.
ifs is not a list; it is a set of characters like strpbrk(2).

i think this is what you want

        for(line in `{ifs=$nl cat}){...}

but i have no idea why one would avoid the read
idiom.  for large input, forking off a read for each
line keeps the memory footprint O(1).

if not dealing with large input, then a few forks don't
matter.

> On the other hand, echo -n is a wart. I wonder, does echo '' -n work?
> (My plan9 machine is off and far away.)

as per plan 9 tradition, the first non-option terminates
option processing.  lindon's echon is not required.  giving
echo -n as its first argument works fine.

- erik

Reply via email to