From owner-freebsd-current Sun Apr 22 16: 2:11 2001 Delivered-To: freebsd-current@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id 600E937B422 for ; Sun, 22 Apr 2001 16:02:06 -0700 (PDT) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.acs.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.11.3/8.11.3) with ESMTP id f3MN1jn113966; Sun, 22 Apr 2001 19:01:45 -0400 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: <20010421201957.D12FD3E09@bazooka.unixfreak.org> References: <20010421201957.D12FD3E09@bazooka.unixfreak.org> Date: Sun, 22 Apr 2001 19:01:40 -0400 To: Dima Dorfman , Jordan Hubbard From: Garance A Drosihn Subject: Re: cp -d dir patch for review (or 'xargs'?) Cc: freebsd-current@FreeBSD.ORG, olli@secnetix.de Content-Type: text/plain; charset="us-ascii" ; format="flowed" Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 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 . It is an error if there is more than one copy of the in the command to execute. Examples: 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 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 = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message