GNU bug report logs - #15727
doc: cp: expand dirs-vs-files with -f/--remove-dest

Previous Next

Package: coreutils;

Reported by: Linda Walsh <coreutils <at> tlinx.org>

Date: Sun, 27 Oct 2013 03:49:02 UTC

Severity: wishlist

Full log


Message #14 received at 15727 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Linda Walsh <coreutils <at> tlinx.org>
Cc: Pádraig Brady <P <at> draigBrady.com>, 15727 <at> debbugs.gnu.org
Subject: Re: bug#15727: Bug: cp <-a|-archive> (w/<-f|--remove-destination>)
 breaks if one of files is a dir and other not
Date: Mon, 28 Oct 2013 21:56:14 +0100
Hi Linda,

On 10/28/2013 08:09 AM, Linda Walsh wrote:
> On 10/27/2013 5:38 PM, Pádraig Brady wrote:
>> So overwriting files with dirs and vice versa
>> is prohibited by POSIX.  The existing cp options
>> do not adjust this aspect. If you don't care what's
>> in the destination at all, why not just rm it before the copy?
> 
> 
> Um --- isn't that what the "--remove-destination" option is supposed to
> do?

"info coreutils 'cp invocation'" says:

  `--remove-destination'
       Remove each existing destination file before attempting to open it
       (contrast with `-f' above).

In this case, "file" really means a regular file (or socket, fifo, ...)
but no directory.  The documentation could be clearer about that ...

> Also note, I tried to use it with the "update" option, [...]

... and it may be a question to discuss whether --remove-destination
should be able to rmdir() emtpy directories, but that GNU extension
should never help you out in the case of non-empty directories.
I got the overall impression that you try to sync a source to a
destination.  Tools like rsync may be better for such a scenario
than cp(1) which is made primarily to

  cp: copy files and directories

Have a nice day,
Berny




This bug report was last modified 6 years and 157 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.