Browse Source

Added -f argument to force file creation (rewrite)

Alois Mahdal 11 years ago
parent
commit
30149d7058
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      bin/mkexec.pl

+ 3
- 1
bin/mkexec.pl View File

@@ -8,7 +8,9 @@ sub usage; sub mkexec; sub guesstype; sub getcmd; sub launch_editor;
8 8
 
9 9
 my $DEFAULT_TYPE = 'pl';
10 10
 my $DEFAULT_MODE = 0755;
11
+my $DEFAULT_FORCE = 0;
11 12
 
13
+my $force = $ARGV[0] == '-f' ? shift : $DEFAULT_FORCE;
12 14
 my $name = shift or usage;
13 15
 my $type = ($ARGV[0] ? shift : guesstype $name);
14 16
 
@@ -35,7 +37,7 @@ $cmds->{editor}->{run}  = "editor '%s'";
35 37
 
36 38
 
37 39
 if (exists $bangs->{$type}) {
38
-    -e $name || mkexec $name, mkbody($type);
40
+    -e $name and not $force || mkexec $name, mkbody($type);
39 41
     chmod $DEFAULT_MODE, $name;
40 42
     launch_editor $name;
41 43
 } else {