[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#15727: Bug: cp <-a|-archive> (w/<-f|--remove-destination>) breaks if
From: |
Pádraig Brady |
Subject: |
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 00:38:09 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
On 10/27/2013 03:48 AM, Linda Walsh wrote:
>
> 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
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?
thanks,
Pádraig.
- bug#15727: Bug: cp <-a|-archive> (w/<-f|--remove-destination>) breaks if one of files is a dir and other not, Linda Walsh, 2013/10/26
- bug#15727: Bug: cp <-a|-archive> (w/<-f|--remove-destination>) breaks if one of files is a dir and other not,
Pádraig Brady <=
- bug#15727: Bug: cp <-a|-archive> (w/<-f|--remove-destination>) breaks if one of files is a dir and other not, Linda Walsh, 2013/10/28
- bug#15727: Bug: cp <-a|-archive> (w/<-f|--remove-destination>) breaks if one of files is a dir and other not, Bernhard Voelker, 2013/10/28
- bug#15727: Bug: cp <-a|-archive> (w/<-f|--remove-destination>) breaks if one of files is a dir and other not, Linda Walsh, 2013/10/28
- bug#15727: Bug: cp <-a|-archive> (w/<-f|--remove-destination>) breaks if one of files is a dir and other not, Bernhard Voelker, 2013/10/29
- bug#15727: Bug: cp <-a|-archive> (w/<-f|--remove-destination>) breaks if one of files is a dir and other not, Philipp Thomas, 2013/10/29
- bug#15727: Bug: cp <-a|-archive> (w/<-f|--remove-destination>) breaks if one of files is a dir and other not, Linda Walsh, 2013/10/29