From owner-freebsd-current Sat Apr 21 6: 6:55 2001 Delivered-To: freebsd-current@freebsd.org Received: from Awfulhak.org (awfulhak.demon.co.uk [194.222.196.252]) by hub.freebsd.org (Postfix) with ESMTP id 5F6C437B422 for ; Sat, 21 Apr 2001 06:06:49 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [172.16.0.12]) by Awfulhak.org (8.11.3/8.11.3) with ESMTP id f3LD7Cb78440; Sat, 21 Apr 2001 14:07:12 +0100 (BST) (envelope-from brian@lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.3/8.11.3) with ESMTP id f3LD64543456; Sat, 21 Apr 2001 14:06:04 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200104211306.f3LD64543456@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: "Rodney W. Grimes" Cc: bsd@bsdhome.com (Brian Dean), schweikh@schweikhardt.net (Jens Schweikhardt), freebsd-current@FreeBSD.ORG, brian@Awfulhak.org Subject: Re: cp -d dir patch for review (or 'xargs'?) In-Reply-To: Message from "Rodney W. Grimes" of "Fri, 20 Apr 2001 21:00:56 PDT." <200104210400.VAA69212@gndrsh.dnsmgr.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 21 Apr 2001 14:06:04 +0100 From: Brian Somers Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > On Fri, Apr 20, 2001 at 07:26:18PM -0700, Rodney W. Grimes wrote: > > > > > > (cat bigfilelist; echo destdir) | xargs cp > > > > > > I like this version of the patch!! It's much much cleaner than > > > hacking up cp or xargs, it even follows the unix principle of > > > using simple tools and glueing them togeather to do bigger > > > jobs, is unix implementation independent, and is very clear > > > in what it does. > > > > It's clean, simple, and unfortunately, totally bogus. > > > > Try: > > > > echo 1 2 3 4 5 6 7 8 9 | xargs -n 4 echo > > > > Now consider what would happen with the above suggested construct with > > a very long file list. > > bleck... try this for your sample: > $ (echo 1 2 3 4 5 6 7 8 9 | xargs -n 4) | while read x; do > > echo -n $x; echo " dst" > > done > 1 2 3 4 dst > 5 6 7 8 dst > 9 dst > $ > > > > > I don't see a problem with adding an option to cp to treat the first > > argument as the target instead of the last argument. It's a simple > > solution, the code change is simple, and it produces the exact desired > > result. What's the problem? > > It's yet another non-portable option. I hate to appear rude, but has anybody in this discussion actually used xargs for what it's meant to be used ? How do you do this in a script: cd /topdir; find . -type f | xargs -i {} cp {} /otherdir/. Before anyone starts writing scripts, consider that {} will be replaced by xargs with (roughly) ARG_MAX - 10 characters worth of the stuff coming off the pipe. If your combined arguments plus environment exceeds ARG_MAX execve(2) will give you E2BIG. > -- > Rod Grimes - KD7CAX @ CN85sl - (RWG25) rgrimes@gndrsh.dnsmgr.net -- Brian Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message