Sfoglia il codice sorgente

Do a backup when forcing new file

Alois Mahdal 11 anni fa
parent
commit
b708dccea7
1 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  1. 4
    2
      bin/mkexec.pl

+ 4
- 2
bin/mkexec.pl Vedi File

@@ -48,8 +48,10 @@ $cmds->{editor}->{run}  = "editor '%s'";
48 48
 ## ''' ##   # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
49 49
 
50 50
 if (exists $bangs->{$type}) {
51
-    -e $name and not $force
52
-        or mkexec $name, mkbody($type);
51
+    $force and -e $name
52
+        and (defined `cp "$name" "$name~"` or die $!);
53
+    (not -e $name or $force)
54
+        and mkexec $name, mkbody($type);
53 55
     chmod $DEFAULT_MODE, $name;
54 56
     launch_editor $name;
55 57
 } else {