- if (-f $dst && $opt_f) {
- print "Warning: $bad; will overwrite!\n";
- $bad = "";
- $overwritten{$dst} = 1;
+ if ($opt_f) {
+ # only files can overwrite each other: check both source and destination
+ if (-f $dst && (scalar @srcfiles == 1)) {
+ print "Warning: $bad; will overwrite!\n";
+ $bad = "";
+ $overwritten{$dst} = 1;
+ }
+ else {
+ $bad = "Can not overwrite '$src' with '$dst'";
+ }