From owner-freebsd-current Sun Apr 22 22:22:12 2001 Delivered-To: freebsd-current@freebsd.org Received: from gndrsh.dnsmgr.net (GndRsh.dnsmgr.net [198.145.92.4]) by hub.freebsd.org (Postfix) with ESMTP id 40F7037B423 for ; Sun, 22 Apr 2001 22:22:09 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.9.3/8.9.3) id WAA76392; Sun, 22 Apr 2001 22:21:08 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <200104230521.WAA76392@gndrsh.dnsmgr.net> Subject: Re: cp -d dir patch for review (or 'xargs'?) In-Reply-To: <200104211306.f3LD64543456@hak.lan.Awfulhak.org> from Brian Somers at "Apr 21, 2001 02:06:04 pm" To: brian@Awfulhak.org (Brian Somers) Date: Sun, 22 Apr 2001 22:21:08 -0700 (PDT) Cc: bsd@bsdhome.com (Brian Dean), schweikh@schweikhardt.net (Jens Schweikhardt), freebsd-current@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > > 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/. > My example should work for that, just replace the initial echo with ``cd /topdir; find . -type f'', and replace your xargs with my script, using -n 100 or -s of some sane value. > 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. No rain here, it is ARG_MAX - 2048: -s size Set the maximum number of bytes for the command line length pro- vided to utility. The sum of the length of the utility name and the arguments passed to utility (including NULL terminators) will be less than or equal to this number. The current default value for size is ARG_MAX - 2048. 2K would be a pretty big env, root default std is about 367 bytes. Yes, that is probably not a portable assumption to make, but it is far better than using non-standard options to xargs. -- Rod Grimes - KD7CAX @ CN85sl - (RWG25) rgrimes@gndrsh.dnsmgr.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message