summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
06e26c8)
print STDERR "\bL";
link($from, $tmp_to) or die "link: $from -> $tmp_to: $!";
print STDERR "\bR";
print STDERR "\bL";
link($from, $tmp_to) or die "link: $from -> $tmp_to: $!";
print STDERR "\bR";
- unless (rename($tmp_to, $to)) {
- my $saved_bang = $!;
- print STDERR "\bU";
- unlink($tmp_to) or warn "unlink: $tmp_to: $!"; # Try, possibly in vain, to clean up
- die "rename: $tmp_to -> $from: $saved_bang";
- }
+ my $saved_bang;
+ $saved_bang = $! unless rename($tmp_to, $to);
+
+ # If $to exists and is a hardlink to $tmp_to (or $from),
+ # rename returns success but $tmp_to still exists.
+ print STDERR "\bU";
+ unlink($tmp_to) or warn "unlink: $tmp_to: $!" if -e $tmp_to;
+
+ die "rename: $tmp_to -> $from: $saved_bang" if $saved_bang;