Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 May 2001 23:31:53 -0400
From:      Garance A Drosihn <drosih@rpi.edu>
To:        Cyrille Lefevre <clefevre@poboxes.com>, Brian Somers <brian@Awfulhak.org>
Cc:        Dima Dorfman <dima@unixfreak.org>, hackers@FreeBSD.ORG
Subject:   Re: xargs(1) "replstr" patch
Message-ID:  <p05100e02b726437b5856@[128.113.24.47]>
In-Reply-To: <n18fnz19.fsf@gits.dyndns.org>
References:  <200105121004.f4CA4gX91830@hak.lan.Awfulhak.org> <n18fnz19.fsf@gits.dyndns.org>

next in thread | previous in thread | raw e-mail | index | archive | help
At 4:09 AM +0200 5/15/01, Cyrille Lefevre wrote:
>Brian Somers <brian@Awfulhak.org> writes:
>
>>  I'd suggest going ahead and committing it ASAP - before people start
>>  ``discussing'' it again :oI
>
>from my point of view, it would be better to implement -i/-I than this
>hack which has no advantage in performance and functionality than :
>
>while read arg; do CMD LINE $arg ARGS; done < test

I think this proves the wisdom of Brian's suggestion...  :-)

    - - - -

Your 'while' loop *will* be more expensive than the result
of:
      cat test | xargs -J [] CMD LINE [] ARGS
although you would probably need a lot of files in 'test'
to really notice the difference...

In fact, from what I can tell, your while loop is exactly
equivalent to:
      cat test | xargs -I {} CMD LINE {} ARGS
You have not re-implemented -J, you have re-implemented -I.
Ie, it is -I which has no real performance benefit, and can
be functionally duplicated in about a hundred different ways.

If the file 'test' contains the lines 'a\nb\nc\nd\n', then
your example will execute:
      CMD LINE a ARGS
      CMD LINE b ARGS
      CMD LINE c ARGS
      CMD LINE d ARGS
I know this is what your example will do, because I just
executed your exact example with that.  It is also what '-I'
will do, as I have just tested THAT on a system which DOES
implement '-I'.

Meanwhile the above-described use of '-J' will result in:
      CMD LINE a b c d ARGS
I also know what 'xargs -J' will do, because I just executed
THAT too.  Please note that I am not trying to be obnoxious
here, I am trying to be courteous.  Dima and I asked for
opinions, you gave your opinion, and I researched what you
suggested.  I am just listing my results of taking the time to
evaluate your suggestion seriously, because we did ask for input.

Please read EXACTLY what -I does (in the standard description)
and EXACTLY what -J does (in the patch committed to -current,
complete with a man page entry that tries to be very precise
as to what -J does).  It may seem silly to take a lot of time
to read all of this and try some examples, but that's exactly
what Dima and I have been doing for the past few weeks.

    - - - -

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...

-- 
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-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p05100e02b726437b5856>