GNU bug report logs -
#8381
cp inconsistency
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8381 in the body.
You can then email your comments to 8381 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#8381
; Package
coreutils
.
(Wed, 30 Mar 2011 12:30:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Thomas Hofmann <thomas <at> savoy-truffle.de>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Wed, 30 Mar 2011 12:30:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello,
two issues:
1) manpage of cp contains obsolete email-address for bug-reporting
2) cp inconsistency when copying a directory to a) a non existing
directory, or b) to an existing directory. Further elaborated below.
cp -a SOME_DIR NOT_YET_EXISTING_DIR
results in a new directory directly containing each entry of SOME_DIR
while:
CP -a SOME_DIR EXISTING_DIR
results in EXISTING_DIR/SOME_DIR
The first result seems to be a reasonable outcome in both cases.
Appending "/" to the directory-names should lead to the same result.
While appending "/." to the target-directory would change the meaning,
and rather lead to the result of the observed second version.
Kind regards,
Thomas
p.s. cp (GNU coreutils) 7.1
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#8381
; Package
coreutils
.
(Wed, 30 Mar 2011 14:04:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 8381 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 03/30/2011 05:56 AM, Thomas Hofmann wrote:
> Hello,
>
> two issues:
> 1) manpage of cp contains obsolete email-address for bug-reporting
The man page is generated from 'cp --help' output; on my Fedora 14
machine, I see this for 'man cp'
REPORTING BUGS
Report cp bugs to bug-coreutils <at> gnu.org
...
GNU coreutils 8.5 November 2010
CP(1)
If the man page doesn't end with the same version as 'cp --version',
then your man pages are out of date, and that is an installation problem
on your end (or perhaps something you should take up with your distro);
if it _is_ up-to-date, then the reporting bugs address should match. If
it doesn't, then paste what you actually see before claiming that it is
wrong.
> 2) cp inconsistency when copying a directory to a) a non existing
> directory, or b) to an existing directory. Further elaborated below.
>
> cp -a SOME_DIR NOT_YET_EXISTING_DIR
>
> results in a new directory directly containing each entry of SOME_DIR
>
> while:
> CP -a SOME_DIR EXISTING_DIR
Did you mean 'cp' instead of 'CP'?
>
> results in EXISTING_DIR/SOME_DIR
This is not a bug - the dual behavior is mandated by POSIX, which
specifically requires that cp first stat() the last argument, then act
differently depending on whether that argument was an existing directory
or not.
>
> The first result seems to be a reasonable outcome in both cases.
> Appending "/" to the directory-names should lead to the same result.
To the source or to the destination, or to both?
> While appending "/." to the target-directory would change the meaning,
> and rather lead to the result of the observed second version.
I'm not sure I follow what you think is wrong or unintuitive. So the
best I can do is state what POSIX requires, and that I believe that GNU
cp meets those requirements:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html
The first synopsis form is denoted by two operands, neither of which are
existing files of type directory. The cp utility shall copy the contents
of source_file (or, if source_file is a file of type symbolic link, the
contents of the file referenced by source_file) to the destination path
named by target_file.
The second synopsis form is denoted by two or more operands where the -R
option is not specified and the first synopsis form is not applicable.
It shall be an error if any source_file is a file of type directory, if
target does not exist, or if target does not name a directory. The cp
utility shall copy the contents of each source_file (or, if source_file
is a file of type symbolic link, the contents of the file referenced by
source_file) to the destination path named by the concatenation of
target, a single <slash> character if target did not end in a <slash>,
and the last component of source_file.
The third synopsis form is denoted by two or more operands where the -R
option is specified. The cp utility shall copy each file in the file
hierarchy rooted in each source_file to a destination path named as follows:
* If target exists and names an existing directory, the name of the
corresponding destination path for each file in the file hierarchy shall
be the concatenation of target, a single <slash> character if target did
not end in a <slash>, and the pathname of the file relative to the
directory containing source_file.
* If target does not exist and two operands are specified, the name
of the corresponding destination path for source_file shall be target;
the name of the corresponding destination path for all other files in
the file hierarchy shall be the concatenation of target, a <slash>
character, and the pathname of the file relative to source_file.
--
Eric Blake eblake <at> redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
Reply sent
to
Pádraig Brady <P <at> draigBrady.com>
:
You have taken responsibility.
(Wed, 30 Mar 2011 14:12:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Thomas Hofmann <thomas <at> savoy-truffle.de>
:
bug acknowledged by developer.
(Wed, 30 Mar 2011 14:12:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 8381-done <at> debbugs.gnu.org (full text, mbox):
On 30/03/11 12:56, Thomas Hofmann wrote:
> Hello,
>
> two issues:
> 1) manpage of cp contains obsolete email-address for bug-reporting
That is fixed in current versions
> 2) cp inconsistency when copying a directory to a) a non existing
> directory, or b) to an existing directory. Further elaborated below.
>
> cp -a SOME_DIR NOT_YET_EXISTING_DIR
>
> results in a new directory directly containing each entry of SOME_DIR
>
> while:
> CP -a SOME_DIR EXISTING_DIR
>
> results in EXISTING_DIR/SOME_DIR
>
> The first result seems to be a reasonable outcome in both cases.
> Appending "/" to the directory-names should lead to the same result.
> While appending "/." to the target-directory would change the meaning,
> and rather lead to the result of the observed second version.
So you would like
cp -a dir dest_dir # copy dir/* to dest_dir/
cp -a dir dest_dir/ # copy dir to dest_dir/
That seems a bit subtle to me.
Currently one can get the first behavior using `cp -aT`
so I'll close this.
Note also the related:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7450
cheers,
Pádraig.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#8381
; Package
coreutils
.
(Wed, 30 Mar 2011 15:56:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 8381 <at> debbugs.gnu.org (full text, mbox):
>> 2) cp inconsistency when copying a directory to a) a non existing
>> directory, or b) to an existing directory. Further elaborated below.
>>
>> cp -a SOME_DIR NOT_YET_EXISTING_DIR
>>
>> results in a new directory directly containing each entry of SOME_DIR
>>
>> while:
>> CP -a SOME_DIR EXISTING_DIR
>>
>> results in EXISTING_DIR/SOME_DIR
>>
>> The first result seems to be a reasonable outcome in both cases.
>> Appending "/" to the directory-names should lead to the same result.
>> While appending "/." to the target-directory would change the meaning,
>> and rather lead to the result of the observed second version.
>
> So you would like
>
> cp -a dir dest_dir # copy dir/* to dest_dir/
> cp -a dir dest_dir/ # copy dir to dest_dir/
No.
I would like that
a) cp -a dir dest_dir
does what
b) cp -a dir previously_not_existing_dest_dir
does already
Consider you have the following directory layout:
/
/dir
/dest_dir
Then - at least in v. 7.1 of coreutils -
b) results in the new directory layout:
/
/dir
/dest_dir
/previously_not_existing_dest_dir
while a) would result in:
/
/dir
/dest_dir/dir
Try it.
The described behaviour is at least counter intuitive.
In order to copy a directory and its contents _into_ another directory
cp -a dir dest_dir/.
already works and is an appropriate statement to express what is
meant. The appended "/." makes it clear that the target is the content
of the directory and not the directory itself. While it seems to be a
slight difference it is actually not.
Please reason about this.
Kind regards,
Thomas
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#8381
; Package
coreutils
.
(Wed, 30 Mar 2011 19:42:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 8381 <at> debbugs.gnu.org (full text, mbox):
On 03/30/2011 08:25 AM, Thomas Hofmann wrote:
> I would like that
> a) cp -a dir dest_dir
> does what
> b) cp -a dir previously_not_existing_dest_dir
> does already
Doesn't "cp -aT dir dest_dir" do what you want?
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 28 Apr 2011 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 14 years and 57 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.