}
}
- if (($bad eq "") && ($src eq $dstDir)) {
+ if (($bad eq "") && ($dst =~ /^$safesrc\//)) {
$bad = "can not move directory '$src' into itself";
}
# Final pass: rename/move
my (@deletedfiles,@addedfiles,@changedfiles);
+$bad = "";
while(scalar @srcs > 0) {
$src = shift @srcs;
$dst = shift @dsts;
if ($opt_n || $opt_v) { print "Renaming $src to $dst\n"; }
if (!$opt_n) {
- rename($src,$dst)
- or die "rename failed: $!";
+ if (!rename($src,$dst)) {
+ $bad = "renaming '$src' failed: $!";
+ if ($opt_k) {
+ print "Warning: skipped: $bad\n";
+ $bad = "";
+ next;
+ }
+ last;
+ }
}
$safesrc = quotemeta($src);
close(H);
}
}
+
+if ($bad ne "") {
+ print "Error: $bad\n";
+ exit(1);
+}