Date: Mon, 14 May 2001 23:52:34 -0700 From: Dima Dorfman <dima@unixfreak.org> To: Peter Pentchev <roam@orbitel.bg> Cc: Garance A Drosihn <drosih@rpi.edu>, Cyrille Lefevre <clefevre@poboxes.com>, Brian Somers <brian@Awfulhak.org>, hackers@FreeBSD.ORG Subject: Re: xargs(1) "replstr" patch Message-ID: <20010515065234.8412C3E0B@bazooka.unixfreak.org> In-Reply-To: <20010515093121.A94119@ringworld.oblivion.bg>; from roam@orbitel.bg on "Tue, 15 May 2001 09:31:22 %2B0300"
next in thread | previous in thread | raw e-mail | index | archive | help
Peter Pentchev <roam@orbitel.bg> writes: > On Mon, May 14, 2001 at 11:31:53PM -0400, Garance A Drosihn wrote: > > Still, let me say that I do hope to get back to 'xargs', and add > > the -I option. I must admit my enthusiasm for doing -I wore off > > after seeing the current code to 'xargs'. Not only is -J more > > useful, but it is much less work to implement (given the current > > code as a starting point) than -I would be. Still, it *would* be > > nice to say we have '-I', just to match what the various standards > > list for options to 'xargs'. > > > > While I do like the idea of adding it, I'll admit that it isn't a > > particularly high priority on my list of things to do... > > Just as a side thought: one we have -J, I guess -I could be done > as simply as emulating -n 1 and falling through to -J :) > Then there would need to be another couple of checks, like -n and -I > or -J and -I not being used simultaneously, but yes, I think it would > really be *that* easy. Sorry, no. -I can be used more than once, and the replstr does not have to be given as a separate pointer in argv. For example, given the input, one\ntwo\nthree\n this command xargs -I [] mv srcdir/[] destdir/[] should generate: mv srcdir/one destdir/one mv srcdir/two destdir/two mv srcdir/three destdir/three This is a simplistic example that can be done in many other ways (including using -J), but it shows what -I is supposed to be able to do. -J doesn't work with the above since it only looks for the replstr once, and will not find it unless it's given as a separate argument. For example, this works: xargs -J [] echo this is [] a test but this does not: xargs -J [] echo this is[] a test That said, -I isn't all that hard to implement. It's just hard to implement without rewriting xargs as it is. However, that may not be a bad thing. -I would pose a performance problem, anyway; it would have to iterate over the command line arguments and standard input more than once, possibly having to cache what it finds. If we special-case -I with something like, if (flag_I_found) { alternate_main_function(ac, av, ...); /*NOTREACHED*/ } ..code as it is now goes here.. then we don't have the problem of destroying the current code, and the performance impact will only be seen if -I is used (which is reasonable). Of course, "not that hard" is relative. Adding -J was rather trivial; the delta is +30 -6, and most of those +30 are simple things like defining or initializing variables. I guess that adding -I would mean adding on the order of 100 or 150 lines; again, not hard, but not something one can do in 10 minutes. Just food for thought, I guess. I'm sure Garance wouldn't mind if someone did this for him :-). Regards, Dima Dorfman dima@unixfreak.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010515065234.8412C3E0B>