Possible issue with awk

Johannes Stezenbach js at sig21.net
Thu Mar 11 13:30:42 UTC 2010


On Thu, Mar 11, 2010 at 12:50:11PM +0100, Denys Vlasenko wrote:
> On Thu, Mar 11, 2010 at 11:47 AM, Johannes Stezenbach <js at sig21.net> wrote:
> > Actually the spec says "Function parameter names shall be local to the
> > function; all other variable names shall be global."
> >
> > -> no special handling for loop variable names, they are global
> 
> Right.
> 
> > And looking at the script, it should work correctly with that:
> >
> >  for (l in libs)
> >    output(l);
> >
> > output() changes l, but that should not be a problem for
> > the given script;
> 
> The problem isn't in changed value of l.
> 
> The problem is that inner loop trashes *the list of strings
> we are iterating over* in outer loop, and thus outer loop's
> iteration is broken (it does not iterate over all strings).

Yes, you are right.  However, I was merely pointing out
that the standard defines the loop variable semantics
and that both gawk and mawk follow that standard in
this respect.


Johannes


More information about the busybox mailing list