Philip Rowlands <[EMAIL PROTECTED]> writes: > I don't know the specs to which GNU cp adheres well enough, but I'd be > surprised if they mandate a sort routine for recursive copying.
POSIX places no requirement here, since these options are an extension to POSIX. The GNU documentation says that "-a" implies "--preserve=links" and that "--preserve-links" means "Preserve in the destination files any links between corresponding source files." Here, Tim wants "cp -a" to preserve in the destination the fact that the source files are different, even though they are already hard links in the destination. This sounds reasonable to me, so I installed the following patch. But I'd like someone with sharp eyes (Jim? :-) to double-check it. In particular, I don't understand what these lines are doing in the existing code: || (x->dereference == DEREF_NEVER && ! S_ISREG (src_sb.st_mode)))) Why should the behavior differ here merely because the source is (say) a character special file? 2004-08-11 Paul Eggert <[EMAIL PROTECTED]> * src/copy.c (copy_internal): When preserving links, unlink a destination with link count greater than one. This is so that commands like "cp -a" don't get confused when copying into a destination that already contains many hard links. Problem reported by Tim Waugh in: http://lists.gnu.org/archive/html/bug-coreutils/2004-08/msg00053.html Index: src/copy.c =================================================================== RCS file: /home/eggert/coreutils/cu/src/copy.c,v retrieving revision 1.170 retrieving revision 1.171 diff -p -u -r1.170 -r1.171 --- src/copy.c 30 Jul 2004 07:51:59 -0000 1.170 +++ src/copy.c 11 Aug 2004 17:19:25 -0000 1.171 @@ -1079,6 +1079,7 @@ copy_internal (const char *src_path, con } else if (! S_ISDIR (dst_sb.st_mode) && (x->unlink_dest_before_opening + || (x->preserve_links && 1 < dst_sb.st_nlink) || (x->dereference == DEREF_NEVER && ! S_ISREG (src_sb.st_mode)))) { _______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-coreutils