Rob Landley wrote:
> On 03/28/2015 04:31 PM, Felix Janda wrote:
> > ---
> >  toys/posix/head.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/toys/posix/head.c b/toys/posix/head.c
> > index 42f945b..8e77b01 100644
> > --- a/toys/posix/head.c
> > +++ b/toys/posix/head.c
> > @@ -56,6 +56,7 @@ void head_main(void)
> >    if (arg && *arg == '-' && arg[1]) {
> >      TT.lines = atolx(arg+1);
> >      toys.optc--;
> > +    toys.optargs++;
> >    }
> > -  loopfiles(toys.optargs+!!arg, do_head);
> > +  loopfiles(toys.optargs, do_head);
> >  }
> 
> Actually I try to avoid modifying toys.optargs in case I expand nofork()
> stuff in future and want to free it on return.

ok, then I don't see how to do is without using another variable.

> When you say "fix", could you give me a test case showing the failure?

The question is rather what still works.

The current code ignores the first non-option argument (where -123 don't
count as options). So something like "head file" will hang.

Sorry for not giving more details before. I viewed it as fixing a very
obvious bug.

Felix
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to