[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cp(1) manual/functionality



Hi,

OpenBSD 2.4 manual for cp(1):
-----------------------------< cut here >-------------------------------
     -f    For each existing destination pathname, remove it and create a new
           file, without prompting for confirmation, regardless of its permis-
           sions.  (The -i option is ignored if the -f option is specified.)
-----------------------------< cut here >-------------------------------

This doesn't match observed behaviour - the old file is not removed -
it is overwritten.

This matters when dealing with hard-linked files.

$ echo foo >a
$ echo wibble >b
$ ln a c
$ ls -li a b c
3615 -rw-r--r--  2 phil  users  4 Jun 26 18:59 a
3616 -rw-r--r--  1 phil  users  7 Jun 26 18:59 b
3615 -rw-r--r--  2 phil  users  4 Jun 26 18:59 c
$ cp -f b a
$ ls -li a b c
3615 -rw-r--r--  2 phil  users  7 Jun 26 18:59 a
3616 -rw-r--r--  1 phil  users  7 Jun 26 18:59 b
3615 -rw-r--r--  2 phil  users  7 Jun 26 18:59 c
$

Which is wrong - the documentation or the code?

(I'm not paranoid enough.  I just lost a file I needed because I was
 trying to do an atomic replace.  Serves me right for trying to be
 clever and not just copying the old one instead).

HTH, HAND
-- 
--> Phil Pennock ; GAT d- s+:+ a23 C++(++++) UL++++/I+++/S+++/B++/H+$ P++@$
L+++ E-@ W(+) N>++ o !K w--- O>+ M V !PS PE Y+ PGP+ t-- 5++ X+ R !tv b++>+++
DI+ D+ G+ e+ h* r y?