[PATCH] adding two new options to 'cp'

Eric Anderson anderson at centtech.com
Mon Jul 31 13:21:08 UTC 2006


On 07/27/06 12:44, Doug Barton wrote:
> Oliver Fromme wrote:
>> Eric Anderson <anderson at centtech.com> wrote:
>>  > I'm tired of trying to use rsync or gcp (which doesn't like symlinks 
>>  > often) to copy trees of files/directories using hard links, so I added 
>>  > the gcp-ish options -a and -l.
>>  > 
>>  > -a is 'archive' mode, which is just a quick form of -PpR.
>>
>> -P is the default anyway, so -a would only replace -Rp.
>> I don't think saving one letter justifies introducing a new
>> option.  You can use an alias or shell function.
>>
>>  > -l is 'link' mode, where regular files get hard linked instead of copied.
>>  > 
>>  > So, you can mimic an entire tree with something like:
>>  > 
>>  > cp -al /from/ /to/
>>  > 
>>  > and it's fast too!
>>
>> You can do the same with existing tools in a portable
>> (and thus preferable) way:
>>
>> cd /from; find -d . | cpio -dumpl /to
> 
> While I don't want to stifle anyone's creativity, I agree with Oliver (and
> other posters) on this one. The Unix way of doing things is small programs
> that do their jobs well, tied together to accomplish bigger things.
> 
> Doug
> 


Honestly, I agree with the 'Unix way', however if we really took that to 
heart, there would be no 'cp' at all.  We'd use dd instead, along with 
find, and chmod/chown.  But we don't - why?  Same reason for adding 
nearly any option.  All the mentions of cpio, pax, tar, etc, are all 
great, and I know of them, but they are harder to remember, more typing, 
less 'compatible' in some cases (not all), possibly more prone to human 
error (typos), etc.

The patch doesn't change any current behavior, nor should it be noticed 
by anyone not looking for it.  However, it is useful, and it does make 
our cp work just like the GNU cp, which eases the migration path for 
linux->FreeBSD users.

I suppose I'm just missing the reason *not* to commit such a simple and 
useful set of options.

Eric



-- 
------------------------------------------------------------------------
Eric Anderson        Sr. Systems Administrator        Centaur Technology
Anything that works is better than anything that doesn't.
------------------------------------------------------------------------


More information about the freebsd-hackers mailing list