[BusyBox] Re: [patch] Why busybox xargs is broken.

Glenn McGrath bug1 at optushome.com.au
Fri Oct 3 10:09:19 UTC 2003

On Fri, 3 Oct 2003 03:24:03 -0600
Erik Andersen <andersen at codepoet.org> wrote:

> There is no need to reinvent getopt here.  bb_getopt_ulflags is a
> much more compact wrapper on top of getopt.  It is admitedly not
> well documented, but it works nicely and produces very compact
> arg parsing.  It should be something like:

One complication with getopt is that the xargs options and the commands
arguments should be kept seperate.


echo "one" | xargs grep -i fred

-i is a grep option, not xargs option, this is currently broken in
busybox xargs.

Im working on an alternative patch, first part of which is.

+       int argc_xargs;
+       /* Determine how many arguments are for xargs */
+       for (argc_xargs = 1; argv[argc_xargs] && argv[argc_xargs][0] == '-'; argc_xargs++);
        bb_opt_complementaly = "pt";
-       a = bb_getopt_ulflags(argc, argv, "tpr");
+       a = bb_getopt_ulflags(argc_xargs, argv, "tpr");


More information about the busybox mailing list