|
@@ -12,7 +12,7 @@ my $DEFAULT_MODE = 0755;
|
12
|
12
|
my $name = shift or usage;
|
13
|
13
|
my $type = ($ARGV[0] ? shift : guesstype $name);
|
14
|
14
|
|
15
|
|
-my $bang = {
|
|
15
|
+my $bangs = {
|
16
|
16
|
pl => `which perl`,
|
17
|
17
|
sh => `which sh`,
|
18
|
18
|
py => `which python`,
|
|
@@ -21,7 +21,7 @@ my $bang = {
|
21
|
21
|
bc => `which bc`
|
22
|
22
|
};
|
23
|
23
|
|
24
|
|
-my $template = {
|
|
24
|
+my $templates = {
|
25
|
25
|
pl => "use strict;\nuse warnings;\n",
|
26
|
26
|
py => "if __name__ == '__main__':\n"
|
27
|
27
|
};
|
|
@@ -34,7 +34,7 @@ $cmds->{editor}->{test} = "editor --version 2>/dev/null";
|
34
|
34
|
$cmds->{editor}->{run} = "editor '%s'";
|
35
|
35
|
|
36
|
36
|
|
37
|
|
-if (exists $bang->{$type}) {
|
|
37
|
+if (exists $bangs->{$type}) {
|
38
|
38
|
-e $name || mkexec $name, mkbody($type);
|
39
|
39
|
chmod $DEFAULT_MODE, $name;
|
40
|
40
|
launch_editor $name;
|
|
@@ -56,8 +56,8 @@ sub guesstype {
|
56
|
56
|
sub mkbody {
|
57
|
57
|
my $type = shift;
|
58
|
58
|
my $tmpl = "";
|
59
|
|
- $tmpl .= $template->{$type} if exists $template->{$type};
|
60
|
|
- return sprintf "#!%s\n%s\n", $bang->{$type}, $tmpl;
|
|
59
|
+ $tmpl .= $templates->{$type} if exists $templates->{$type};
|
|
60
|
+ return sprintf "#!%s\n%s\n", $bangs->{$type}, $tmpl;
|
61
|
61
|
}
|
62
|
62
|
|
63
|
63
|
sub mkexec {
|