Tcl Source Code

View Ticket
Login
Ticket UUID: 1432269
Title: [file copy] fails to recursively copy directory if it exists
Type: Bug Created on: 2006-02-15 16:14:53
Submitter: matzek Assigned to: dgp
Subsystem: 37. File System Severity:
Priority: 5 Medium Last modified: 2008-07-01 22:40:50
Status: Open Closed by: vincentdarley
Resolution: Rejected Closed on: 2006-02-15 20:50:22
Version: obsolete: 8.4.12
Description:
Hi *,

copying directories recursively fails in certain
circumstances.

Easiest way to reproduce:

Have a directory foo/ and do not have a file/directory
bar (otherwise it would just be a step less).

% file copy -- foo bar

-> Now we have a directory bar/

% file copy -- foo bar

-> Fine too, we now have a directory bar/foo/

% file copy -- foo bar

error copying "foo" to "bar/foo": file already exists

-> Which is true, but nonsense as we talk about
directories in both cases. It should just detect that
directory exists already and continue with copying the
stuff below foo/. See POSIX behavior of "cp -R" for
reference.

Tested on SuSE Linux 10.0.

kind regards -- Matthias Kraft
User Comments:
vincentdarley added on 2006-02-16 03:50:21:
Logged In: YES 
user_id=32170

This is how Tcl's 'file copy' command is documented to behave. If you'd prefer 
some other behaviour, you can easily enough code up a procedure to do your 
own kind of copying.

You might be interested in what 'file copy -force' does; perhaps closer to your 
liking?

Vince.

matzek added on 2006-02-16 04:11:26:
Logged In: YES 
user_id=330806

Hi Vincent,

sorry for reopening, but I may have been a little bit too
short in my initial post.

You are right -force is documented to override here, but it
doesn't. It doesn't matter whether or not -force is specified.

Furthermore - but this might be a lack of my english skills
- the documentation make a distinction between how
directories and files are handled. So I read there that for
directories -force isn't needed to get the content
recursively copied...

OTOH it could also be that I don't really get a grip on the
idea of "overwriting a directory"...

kind regards -- Matthias Kraft

matzek added on 2008-07-01 22:40:50:
Logged In: YES 
user_id=330806
Originator: YES

I still find the behavior surprising, but of course found my way around it.
So does it still - if ever - qualify as a bug? If not just close it.

Thanks
-- Matthias Kraft