Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Apr 2001 17:27:04 +0200 (CEST)
From:      Oliver Fromme <olli@secnetix.de>
To:        freebsd-current@FreeBSD.ORG
Subject:   Re: cp -d dir patch for review (or 'xargs'?)
Message-ID:  <200104211527.RAA06452@lurza.secnetix.de>
In-Reply-To: <21060.987865322@axl.fw.uunet.co.za>

next in thread | previous in thread | raw e-mail | index | archive | help
Sheldon Hearn <sheldonh@uunet.co.za> wrote:
 > On Sat, 21 Apr 2001 16:51:24 +0200, Oliver Fromme wrote:
 > > That can overflow your shell's command line limit (at the
 > > "for" command).  True, our /bin/sh doesn't has such a
 > > limit, AFAIK, but there _are_ shells that do).
 > 
 > That's actually my point.  What's being proposed is a non-standard
 > extension to work around a problem on a system that already doesn't have
 > the problem.

Maybe I didn't make myself clear enough.
We _do_ have a problem.

Not all users use /bin/sh.  Scripts needn't be written
in /bin/sh, and xargs can be used interactively, too (I
use it a lot).  Just because _our_ xargs works fine with
_our_ /bin/sh doesn't mean there is no problem.

And then there's the gross efficiency problem.  Try these
alternatives and compare how long they take:

   for i in `find /usr/ports -type f`; do
      cat $i >/dev/null
   done

   find /usr/ports -type f | xargs cat >/dev/null

The latter is a hell of a lot faster.  (The example uses
"cat" just because it works with xargs.)

By the way, the first (inefficient) approach could be
rewritten like this:

   find /usr/ports -type f | while read i; do
      cat $i >/dev/null
   done

This avoid the potential line limit problem, but of course
it's just as inefficient.

Regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"All that we see or seem is just a dream within a dream" (E. A. Poe)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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