This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
installman patch: Dont remove manpages unless the new one is good
[perl5.git] / installman
index 13cb75f..76ab23c 100755 (executable)
@@ -90,13 +90,15 @@ sub runpod2man {
        $manpage =~ s#\.p(m|od)$##;
        $manpage =~ s#/#::#g;
        $manpage = "${mandir}/${manpage}.${manext}";
-       &cmd("$pod2man $mod > $manpage");
-       if (-z $manpage) {
-           print STDERR "unlink $manpage\n";
-           unless ($notify) {
-               unlink($manpage) || warn "cannot unlink $manpage: $!";
-           } 
-       } 
+       &cmd("$pod2man $mod > $manpage.tmp");
+       if (-s "$manpage.tmp") {
+           rename("$manpage.tmp", $manpage) && next;
+           warn "cannot rename to $manpage: $!";
+       }
+       print STDERR "unlink $manpage.tmp\n";
+       unless ($notify) {
+           unlink("$manpage.tmp") || warn "cannot unlink $manpage.tmp: $!";
+       }
     }
     chdir "$builddir" || die "Unable to cd back to $builddir directory!\n$!\n";
 }