Browse Source

Do not launch editor by default

Alois Mahdal 10 years ago
parent
commit
93bf2c3b4e
1 changed files with 8 additions and 3 deletions
  1. 8
    3
      bin/mkexec

+ 8
- 3
bin/mkexec View File

@@ -9,6 +9,7 @@ sub usage; sub mkexec; sub guesstype; sub getcmd; sub launch_editor;
9 9
 my $DEFAULT_TYPE = 'sh';
10 10
 my $DEFAULT_MODE = 0755;
11 11
 my $DEFAULT_FORCE = 0;
12
+my $DEFAULT_EDIT = 0;
12 13
 
13 14
 
14 15
 ## .... ##   . . .  .   .    .     .      .       .        .         .
@@ -16,11 +17,15 @@ my $DEFAULT_FORCE = 0;
16 17
 ## '''' ##   ' ' '  '   '    '     '      '       '        '         '
17 18
 
18 19
 my $force = $DEFAULT_FORCE;
19
-my $name; my $type;
20
+my $name; my $type; my $edit;
20 21
 
21 22
 foreach (@ARGV) {
22 23
     if (m/-f|--force/) {
23 24
         $force++;
25
+    } elsif (m/-e|--edit/) {
26
+        $edit++;
27
+    } elsif (m/-E|--no-edit/) {
28
+        $edit = 0;
24 29
     } elsif (defined $name) {
25 30
         $type = $_;
26 31
     } else {
@@ -63,7 +68,7 @@ if (exists $bangs->{$type}) {
63 68
     (not -e $name or $force)
64 69
         and mkexec $name, mkbody($type);
65 70
     chmod $DEFAULT_MODE, $name;
66
-    launch_editor $name;
71
+    launch_editor $name if $edit;
67 72
 } else {
68 73
     die "unknown type: $type\n";
69 74
 }
@@ -74,7 +79,7 @@ if (exists $bangs->{$type}) {
74 79
 ## '''' ##   ..............................................................-'
75 80
 
76 81
 sub usage {
77
-    print STDERR "usage: $0 [-f] filename [type]\n";
82
+    print STDERR "usage: $0 [-f|-E] filename [type]\n";
78 83
     exit 0;
79 84
 }
80 85