Trap: For soft-links this command copies the link and not the file the link refers to. Example:
Question: How do I recursively copy from one directory structure to another that already exists?file copy will not recursively overwrite:
[gaoithe]: It was not obvious to me how to properly check for file copy error. One simply catches calls to file copy (same for other file commands such as stat).
AMG: In Tcl 8.6, running [file copy] with no arguments produces this error message:
# touch a ; ln -s a b # ls -l a b ... 0 a ... 1 b -> a # tclsh % file copy b c ; exit # ls -l a b c ... 0 a ... 1 b -> a ... 1 c -> a
Question: How do I recursively copy from one directory structure to another that already exists?file copy will not recursively overwrite:
% file copy -force /home/path1/dirs /home/path2 % file copy -force /home/path1/dirs /home/path2 error copying "/home/path1/dirs" to "/home/path2/dirs": file already existsContrast with the following UNIX command that does not raise an error:
# cp -rf /home/path1/dirs/* /home/path2/dirs
[gaoithe]: It was not obvious to me how to properly check for file copy error. One simply catches calls to file copy (same for other file commands such as stat).
if {[catch {file copy -force $sFrom $sTo} sError]} { FAIL "file copy failed: err:$sError to:$sTo" }
AMG: In Tcl 8.6, running [file copy] with no arguments produces this error message:
wrong # args: should be "file copy ?-option value ...? source ?source ...? target"Only two possible options are defined, -force and --, and neither takes an argument. Additionally, --, if specified, must be the last option. So I think the error message should instead be:
wrong # args: should be "file copy ?-force? ?--? source ?source ...? target"I'm not sure if this is considered a bug. The behavior is technically correct but could be improved. So I'm reporting it here rather than on the bug tracker. I haven't checked the source, but it could be that [file copy] shares the Tcl_WrongNumArgs() invocation with lots of other commands in the ensemble, and there aren't enough hooks to customize the option descriptions. If that's the case, "fixing" this could well be more trouble than it's worth.