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