At 1:19 PM -0700 4/21/01, Dima Dorfman wrote:
>Does that mean everyone is blind and missed my arrogant
>cross-post of the amazingly short patch to do this, or
>are we just interested in discussing it and not testing
>the implementation? ;-)

Well, I'm in the middle of a massive reorganization of
all my machines at home (to fit in a new G4 Cube!), so
I'm not paying as much attention to this as I would like.
I think it's really great that Dima has volunteered to do
the work...    :-)

 From what I have been following, you had one patch to add
the '-I' and '-i' options, and a different patch to add
the newly proposed '-Y' option.  Right?

The '-I' option is of interest because it is used in some
other OS's, and is even defined in some standards, such as
the SingleUnixSpec.  From that:

    -I replstr
    Insert mode: utility will be executed for each line from
    standard input, taking the entire line as a single argument,
    inserting it in arguments for each occurrence of replstr.
    A maximum of five arguments in arguments can each contain
    one or more instances of replstr. Any blank characters at
    the beginning of each line are ignored. Constructed arguments
    cannot grow larger than 255 bytes. Option -x is forced on.

I think that if we're going to add a '-I', then we should
follow that description.  Note that '-I', by definition,
forces '-n 1'.  It will always pick up only one file from
the input to xargs per command that xarg will generate.
It allows things like:

    1.  The following will move all files from directory
        $1 to directory $2:
        ls $1 | xargs -I {} mv $1/{} $2/{}

[that example is a subset of an example from the standard]
One might argue whether there are alternate ways to get the
same effect.  However, in this case we're just trying to add
an option which is ALREADY described as a standard option to
this command.  I would think the only debate is whether Dima's
patch results in behavior which does indeed conform to the
written standard(s).

The newly proposed '-Y' option is similar, except that it
does NOT force '-n 1', and it should replace only ONE
occurrence of the replstr.  I'd be happy with any other
letter instead of '-Y'.  I only picked that letter because
it didn't seem to be used by any version of 'xargs' that I
personally work with.  We have a lot more room for debate
on this one, because we're making it up.

My thoughts on '-Y' are something like:

    -Y replstr
    Alternate insert mode: The number of arguments included
    on the 'utility' is exactly the same as if -Y was not
    specified.  The only difference is that those arguments
    will replace <replstr> in the command(s) generated by
    xargs, instead of appending the arguments at the end
    of those commands.
    In the string to execute, there can be only one copy
    of the <replstr>.  It is an error if there is more
    than one copy of the <replstr> in the command to

       ls -1 *2000* | xargs -Y [] cp -p [] /year/y2k

         will take all files which have '2000' in their
         name, and copy them to the directory /year/y2k

       ls $1 | xargs -Y [] mv $1/[] $2/[]

         will generate an error message, because the
         <replstr> can only be replaced once, and we
         don't want to guess which copy of [] should
         be replaced.

I also like the idea of allowing:
        '-i' means exactly the same as '-I {}'
and    '-y' means exactly the same as '-Y []'
Note that I would not allow an optional argument to be included
on '-i', even though some standards do allow that for backward
compatibility.  Since I would rather not allow that, perhaps it
would be better to not even bother with '-i' and '-y'.

The -I, -i, -Y, and -y options are mutually exclusive.  If more
than one is specified, then the last one specified will take
effect.  Any attempt to do this "right" should probably be
careful that '-I' only forces '-n 1' if it is not overridden
by a later '-Y'.

I must admit I haven't really looked thru Dima's patch to see
if it meets all these criteria.  I did look at OpenBSD's and
NetBSD's xargs, to see if they had any other options that we
might want to add (they didn't seem to), or if they would have
any trouble adding the same option(s).  My intent here is to
at least describe what I was thinking of in precise-enough
terms that people can decide if the implementation is right.

And in case it isn't obvious, I'll say once again that I wouldn't
complain if someone comes up with a better letter than '-Y' to
use for this new option...  :-)  If '-I' stands for "insert mode",
then what should this mode be called, and what letter would be a
good match to it?  Maybe '-J', for "Just-insert-once mode"?   :-)
That would also get it listed right next to -I...

Garance Alistair Drosehn            =   [EMAIL PROTECTED]
Senior Systems Programmer           or  [EMAIL PROTECTED]
Rensselaer Polytechnic Institute    or  [EMAIL PROTECTED]

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to