Browse Source

Do a backup when forcing new file

Alois Mahdal 11 years ago
parent
commit
b708dccea7
1 changed files with 4 additions and 2 deletions
  1. 4
    2
      bin/mkexec.pl

+ 4
- 2
bin/mkexec.pl View File

48
 ## ''' ##   # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
48
 ## ''' ##   # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
49
 
49
 
50
 if (exists $bangs->{$type}) {
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
     chmod $DEFAULT_MODE, $name;
55
     chmod $DEFAULT_MODE, $name;
54
     launch_editor $name;
56
     launch_editor $name;
55
 } else {
57
 } else {