Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-07-01
22:40 • Ticket [1432269fff] file copy fails to recursively copy directory if it exists... artifact: 6b54870dc7 user: matzek
2006-02-16
04:11 • Open ticket [1432269fff]. artifact: 2201f449f2 user: matzek
03:50 • Ticket [1432269fff]: 2 changes artifact: 1ab3721aed user: vincentdarley
03:50 • Ticket [1432269fff]: 5 changes artifact: d76ec799c3 user: vincentdarley
03:50 • Closed ticket [1432269fff]. artifact: f1c155a1bc user: vincentdarley
2006-02-15
16:14 • New ticket [1432269fff]. artifact: 593f2a2dd3 user: matzek

[file copy] fails to recursively copy directory if it exists

Open1432269fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 18 years ago
Descriptionplain2006-02-15 16:14:53
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
vincentdarley Closed ticket [1432269fff]. [History diff]2006-02-16 03:50:20
vincentdarleyplain2006-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.
vincentdarley Ticket [1432269fff]: 2 changes [History diff]2006-02-16 03:50:22
matzekplain2006-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
matzekplain2008-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
Log in (anonymous is fine) to add a comment.