mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 22:25:23 +00:00
Handle perl -T checks
This commit is contained in:
parent
9b01da77ba
commit
beca89999e
1 changed files with 22 additions and 11 deletions
33
t/test.t
33
t/test.t
|
@ -14,13 +14,14 @@ use vars qw/*name *dir *prune/;
|
||||||
my $num_plugins = 0;
|
my $num_plugins = 0;
|
||||||
|
|
||||||
sub wanted {
|
sub wanted {
|
||||||
my ( $dev, $ino, $mode, $nlink, $uid, $gid, $interpreter );
|
my ( $dev, $ino, $mode, $nlink, $uid, $gid, $interpreter, $arguments );
|
||||||
|
|
||||||
( ( $dev, $ino, $mode, $nlink, $uid, $gid ) = lstat($_) )
|
( ( $dev, $ino, $mode, $nlink, $uid, $gid ) = lstat($_) )
|
||||||
&& -f _
|
&& -f _
|
||||||
&& ( $interpreter = hashbang("$_") )
|
&& ( ( $interpreter, $arguments ) = hashbang("$_") )
|
||||||
|
&& ($interpreter)
|
||||||
&& ++$num_plugins
|
&& ++$num_plugins
|
||||||
&& process_file( $_, $name, $interpreter );
|
&& process_file( $_, $name, $interpreter, $arguments );
|
||||||
}
|
}
|
||||||
|
|
||||||
File::Find::find( { wanted => \&wanted }, 'plugins' );
|
File::Find::find( { wanted => \&wanted }, 'plugins' );
|
||||||
|
@ -31,17 +32,20 @@ sub hashbang {
|
||||||
my $firstline = <$file>;
|
my $firstline = <$file>;
|
||||||
close $file;
|
close $file;
|
||||||
|
|
||||||
$firstline =~ m{ ^\#! # hashbang
|
$firstline =~ m{ ^\#! # hashbang
|
||||||
\s* # optional space
|
\s* # optional space
|
||||||
(?:/usr/bin/env\s+)? # optional /usr/bin/env
|
(?:/usr/bin/env\s+)? # optional /usr/bin/env
|
||||||
(?<interpreter>\S+) # interpreter
|
(?<interpreter>\S+) # interpreter
|
||||||
}xm;
|
(?:\s+
|
||||||
|
(?<arguments>[^\n]*) # optional interpreter arguments
|
||||||
|
)?
|
||||||
|
}xms;
|
||||||
|
|
||||||
return $+{interpreter};
|
return ($+{interpreter}, $+{arguments});
|
||||||
}
|
}
|
||||||
|
|
||||||
sub process_file {
|
sub process_file {
|
||||||
my ( $file, $filename, $interpreter ) = @_;
|
my ( $file, $filename, $interpreter, $arguments ) = @_;
|
||||||
use v5.10.1;
|
use v5.10.1;
|
||||||
|
|
||||||
if ( $interpreter =~ m{/bin/sh} ) {
|
if ( $interpreter =~ m{/bin/sh} ) {
|
||||||
|
@ -76,8 +80,15 @@ sub process_file {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elsif ( $interpreter =~ m{perl} ) {
|
elsif ( $interpreter =~ m{perl} ) {
|
||||||
|
my $command;
|
||||||
|
if ($arguments =~ m{-.*T}mx) {
|
||||||
|
$command = [ 'perl', '-cwT', $file ];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$command = [ 'perl', '-cw', $file ];
|
||||||
|
}
|
||||||
run_check(
|
run_check(
|
||||||
{ command => [ 'perl', '-cw', $file ],
|
{ command => $command,
|
||||||
description => 'perl syntax check',
|
description => 'perl syntax check',
|
||||||
filename => $filename
|
filename => $filename
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue