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

Rob Landley rob at landley.net
Mon Oct 6 20:09:00 UTC 2003


I didn't get this patch.

> >   + * BUGS: -p doesnt accept user input
> > + *
> >
> > Really?
>
> The spec says input is supposed to come from /dev/tty, often filenames
> for xargs comes from stdin, so user input for confirmation cannot.

"often"?  The spec says:

> The xargs utility shall construct a command line consisting of the utility
> and argument operands specified followed by as many arguments read in
> sequence from standard input as fit in length and number constraints
> specified by the options.

How do you use xargs without piping stuff into stdin?

> e.g.
> $ echo "./README" | xargs -p ls -l
> ls -l ./README ?...y
> -rw-r--r--    1 bug1     users        4724 Aug  9 09:41 ./README
>
> $ echo "./README" | ./busybox xargs -p ls -l
> ls -l ./README  ?...bug1 at home busybox $
>
> But this is a bad example because i demonstrate my patch to xargs breaks
> something else.
>
> $ echo "README" | ./busybox xargs ls -al
> ls: README : No such file or directory
>
> $ ls README
> README

You know, I'm fairly cerrtain the patch I posted had the correct behavior and 
the infrastructure to add the rest of the posix functionality.  (I banged on 
it rather a lot to get it that way.)

Oh well. :)

> > +if (wpid == -1 && errno == ECHILD) {
> > +  	                         /* we missed its termination */
> > +  	                         break;
> > +  	                 }
> >
> >
> > Why?! We generate ONE child and wait die her. This code not required.
>
> Im not sure where this code comes from.

Beats me.  There's a gnu extension to run multiple commands in parallel, but 
I'm not personally going there just now.  (99% of all usages of this thing 
I've ever seen were "command | xargs othercommand -options".  If we just had 
xargs work correctly with no options, life would be good.  Unfortunately, the 
implementation of xargs was apparently done by somebody who had never used 
it, and broke commands that relied on receiving multiple arguments, like grep 
and tar.)

Glenn: your patch is in cvs now?

> Glenn

Rob



More information about the busybox mailing list