From owner-freebsd-current Tue Apr 24 16:29:41 2001 Delivered-To: freebsd-current@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 77B6237B423 for ; Tue, 24 Apr 2001 16:29:37 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from spike.unixfreak.org (spike [63.198.170.139]) by bazooka.unixfreak.org (Postfix) with ESMTP id 1ACA13E2A; Tue, 24 Apr 2001 16:29:37 -0700 (PDT) To: Garance A Drosihn Cc: freebsd-current@FreeBSD.ORG Subject: Re: cp -d dir patch for review (or 'xargs'?) In-Reply-To: ; from drosih@rpi.edu on "Sun, 22 Apr 2001 19:01:40 -0400" Date: Tue, 24 Apr 2001 16:29:36 -0700 From: Dima Dorfman Message-Id: <20010424232937.1ACA13E2A@bazooka.unixfreak.org> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Garance A Drosihn writes: > 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? No, not quite. It's the same patch. The second one just has the 'Y' option renamed to 'I' because I thought they did the same thing: they don't. > > 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: Adding support for 'I' the way it's described above wouldn't be a trivial as it was to add 'Y'. The latter adds about 15 lines, while the former may involve some restructuring of the code. Xargs compiles the arguments to as an array of pointers. It also has assumptions that argv is only touched in the begining. It wasn't a problem for -Y since it doesn't support the replstr being embedded in an argument (e.g., for a replstr of "{}", "something{}" will not work as one arugment, only "{}" will), and it didn't have to touch argv more than twice (I just added a small loop before all invocations of run()). With -I, it'd probably be necessary to put a large chuck of what is now main() inside a loop. It's not exactly rocket science, but not something I can whip up in an hour, either. I'll see what I can do probably later this week. Dima Dorfman dima@unixfreak.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message