Subject: bug#8381: closed (Re: bug#8381: cp inconsistency)

From: Thomas Hofmann <[email-masked]>
Date: Wed, 30 Mar 2011 17:25:53 +0200

>> 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