瀏覽代碼

Do a backup when forcing new file

Alois Mahdal 11 年之前
父節點
當前提交
b708dccea7
共有 1 個檔案被更改,包括 4 行新增2 行删除
  1. 4
    2
      bin/mkexec.pl

+ 4
- 2
bin/mkexec.pl 查看文件

@@ -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 {