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).
# 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"
}