lintian: r1391 - in trunk: checks debian
Author: djpig
Date: 2008-06-17 23:39:49 +0200 (Tue, 17 Jun 2008)
New Revision: 1391
Modified:
trunk/checks/scripts
trunk/debian/changelog
Log:
* checks/scripts:
+ Improve script_is_evil_and_wrong() to catch more scripts.
Patch by Adam D. Barratt.
Modified: trunk/checks/scripts
===================================================================
--- trunk/checks/scripts 2008-06-17 20:42:46 UTC (rev 1390)
+++ trunk/checks/scripts 2008-06-17 21:39:49 UTC (rev 1391)
@@ -767,16 +767,40 @@
my $ret = 0;
open (IN, '<', $filename) or fail("cannot open $filename: $!");
my $i = 0;
+ my $var = "0";
local $_;
while (<IN>) {
- chomp;
- next if /^#/o;
- next if /^$/o;
- last if (++$i > 20);
- if (/(^\s*|\beval\s*\'|;\s*)exec\s*.+\s*.?\$0.?\s*(--\s*)?(\${1:?\+)?.?\$(\@|\*)/o) {
- $ret = 1;
- last;
- }
+ chomp;
+ next if m/^#/o;
+ next if m/^$/o;
+ last if (++$i > 55);
+ if (m~
+ # the exec should either be "eval"ed or a new statement
+ (^\s*|\beval\s*[\'\"]|(;|&&)\s*)
+
+ # eat anything between the exec and $0
+ exec\s*.+\s*
+
+ # optionally quoted executable name (via $0)
+ .?\$$var.?\s*
+
+ # optional "end of options" indicator
+ (--\s*)?
+
+ # Match expressions of the form '${1+$@}', '${1:+"$@"',
+ # '"${1+$@', "$@", etc where the quotes (before the dollar
+ # sign(s)) are optional and the second (or only if the $1
+ # clause is omitted) parameter may be $@ or $*.
+ #
+ # Finally the whole subexpression may be omitted for scripts
+ # which do not pass on their parameters (i.e. after re-execing
+ # they take their parameters (and potentially data) from stdin
+ .?(\${1:?\+.?)?(\$(\@|\*))?~x) {
+ $ret = 1;
+ last;
+ } elsif (/^\s*(\w+)=\$0;/) {
+ $var = $1;
+ }
}
close IN;
return $ret;
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2008-06-17 20:42:46 UTC (rev 1390)
+++ trunk/debian/changelog 2008-06-17 21:39:49 UTC (rev 1391)
@@ -18,6 +18,8 @@
the limits of the outer pair far easier. Patch by
Adam D. Barratt.
+ [FL] Improve heredoc detection. Patch by Adam D. Barratt.
+ + [FL] Improve script_is_evil_and_wrong() to catch more scripts.
+ Patch by Adam D. Barratt.
* checks/watch-file{,.desc}:
+ [FL] Check for more Debian specific strings in version
number. Issue an info tag if the watch file uses
Reply to: