Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Apr 2001 22:21:08 -0700 (PDT)
From:      "Rodney W. Grimes" <freebsd@gndrsh.dnsmgr.net>
To:        brian@Awfulhak.org (Brian Somers)
Cc:        bsd@bsdhome.com (Brian Dean), schweikh@schweikhardt.net (Jens Schweikhardt), freebsd-current@FreeBSD.ORG
Subject:   Re: cp -d dir patch for review (or 'xargs'?)
Message-ID:  <200104230521.WAA76392@gndrsh.dnsmgr.net>
In-Reply-To: <200104211306.f3LD64543456@hak.lan.Awfulhak.org> from Brian Somers at "Apr 21, 2001 02:06:04 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
> > > 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




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