-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.pl
executable file
·34 lines (30 loc) · 920 Bytes
/
runner.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env perl
# Execute 1st arg with perl or python, depending on
# extension (.t, .py or .pl).
# Should work perfectly well on non-windows platforms
# as well, but isn't needed there as they can
# use the shebang line.
use strict;
use warnings;
use File::Basename;
use File::Which;
use Carp::Assert;
my $windows=($^O=~/Win/)?1:0;
assert $windows, "running on windows";
my $script = $ARGV[0];
($_,$_,my $suffix) = fileparse($script, qw(t py pl));
my @args;
if ($suffix eq "py") {
my $python3 = which "python3";
@args = ($python3, $script);
} elsif ($suffix eq "t" || $suffix eq "pl") {
my $perl = which "perl";
shift @ARGV;
# see perl --help.
# arguments are `perl [switches] [--] [programfile] [arguments]`
@args = ($perl, "--", $script, @ARGV);
} else {
die "unrecognized suffix $suffix for file $script - couldn't work out interpreter";
}
warn "bout to exec @args";
exec { $args[0] } @args;