[Toybox] [PATCH] xargs: fix -E.

enh enh at google.com
Mon Oct 21 21:39:25 PDT 2019


On Mon, Oct 21, 2019 at 7:45 PM Rob Landley <rob at landley.net> wrote:
>
> Sorry, my description for 4e0d246ec98f wasn't helpful, but it included:
>
> -      if (TT.E && strstart(&save, TT.E)) return (char *)2;
> +      if (TT.E && strstart(&ss, TT.E) && ss == s) return (char *)2;
>
> $ echo one potato two | ./toybox xargs -n1 -E pot
> one
> potato
> two

i assumed the original intent was to short circuit most string
comparisons because the length didn't match, so i tried to preserve
that. but i'm sure someone will tell us if this causes issues in
practice.

> I started down that rathole because adding a ran_once special case variable
> seemed a bit inelegant and when I started reexamining the logic it was one of
> those "pull the thread on the sweater" things and I really want  to redo the
> whole thing based on do_lines... but I think I should hold off on the working
> stuff and focus on the pending directory for now.

sgtm. (though note that xargs is definitely _not_ working yet --- see
my ping on the other patch, and let me know if you're unhappy with the
findutils hack and want to see if we can do it "properly" instead.)

on the good news front, i found time to re-test the current toybox
find (because i couldn't remember anything left to fix), and haven't
found any issues, so i'll be experimentally flipping the switch on
that this week to see what i've missed...

> Rob
>
> On 10/21/19 12:39 AM, enh via Toybox wrote:
> > ping?
> >
> > On Fri, Oct 18, 2019 at 5:22 PM enh <enh at google.com> wrote:
> >>
> >> 89a8d00e470f1999a62ceea81269af2f39c655ba broke -E by switching to a
> >> prefix match. Add the missing test and fix the bug, but caching the
> >> length of the -E argument because the call to strlen(3) on every single
> >> piece of input presumably motivated the change that introduced the bug.
> >> ---
> >>  tests/xargs.test   | 2 +-
> >>  toys/posix/xargs.c | 6 +++++-
> >>  2 files changed, 6 insertions(+), 2 deletions(-)
> > _______________________________________________
> > Toybox mailing list
> > Toybox at lists.landley.net
> > http://lists.landley.net/listinfo.cgi/toybox-landley.net
> > .
> >



More information about the Toybox mailing list