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


View this message in rfc822 format

From: Linda Walsh <coreutils <at> tlinx.org>
To: 15727 <at> debbugs.gnu.org
Subject: bug#15727: Bug: cp <-a|-archive> (w/<-f|--remove-destination>) breaks if one of files is a dir and other not
Date: Sat, 26 Oct 2013 20:48:15 -0700
I was trying to update a copy of /var (=>/root2/var).
It issues non-fatal, failure messages when copying from or to
a non-dir entry to a dir entry.

I tried -a to force the removal of the target dir, or target file.

It didn't work.

I tried --remove-destination, which is clearly not "file" specific
(i.e. should remove dir), it didn't work either.

The problem doesn't happen with pipes or sockets overwriting
files or any combo... seems just dirs are a problem.

mkdir a
touch a/file2dir
mkdir a/dir2file
cp -a a b
mv a/file2dir a/x
mv a/dir2file a/file2dir
mv a/x a/dir2file
---
state=

> ll a b
a:
total 0
-rw-rw-r-- 1 0 Oct 26 20:37 dir2file
drwxrwxr-x 2 6 Oct 26 20:37 file2dir/
b:
total 0
drwxrwxr-x 2 6 Oct 26 20:37 dir2file/
-rw-rw-r-- 1 0 Oct 26 20:37 file2dir

now try copying new changes from 'a' to 'b' -- can't do it.

> cp -a a/. b/.
cp: cannot overwrite non-directory ‘b/././file2dir’ with directory ‘a/./file2dir’
cp: cannot overwrite directory ‘b/././dir2file’ with non-directory


-a/--archive is suppose to duplicate *types* on the target -- it should
be able to make either change without --force or pre-removal,
HOWEVER,

I'd suggest
1) allowing directories to overwrite files as that seems reasonable...t
and
2) with either -f OR --remove-destination, a file would overwrite a directory 
(dir removed).
2b)  One might argue that with -f, where dest is a file the failure comes first, 
aborting a try
for removal; however, certainly, with --remove-destination, the destination 
(whatever it is)
should be removed 1st and no error should be occurring.

Version: (on suse linux)...

cp (GNU coreutils) 8.21 - Copyright (C) 2013






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.