Author: adam-guest
Date: 2008-07-07 13:36:12 +0000 (Mon, 07 Jul 2008)
New Revision: 1564

Modified:
   trunk/debian/changelog
   trunk/scripts/checkbashisms.pl
Log:
Catch shell script wrappers which use "foo $0 $@ &\nexec true"

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-07-07 12:42:11 UTC (rev 1563)
+++ trunk/debian/changelog      2008-07-07 13:36:12 UTC (rev 1564)
@@ -8,6 +8,7 @@
       and "ulimit" and the "echo with unsafe backslash" checks
     + Fix a false-positive in the "source script with arguments check"
     + Treat """" as "" when removing quotes
+    + Catch shell script wrappers which use "foo $0 $@ &\nexec true"
   * debchange: Also collapse UNRELEASED stanzas when -d is used
   * debcheckout:
     + Improve git repository handling with --file

Modified: trunk/scripts/checkbashisms.pl
===================================================================
--- trunk/scripts/checkbashisms.pl      2008-07-07 12:42:11 UTC (rev 1563)
+++ trunk/scripts/checkbashisms.pl      2008-07-07 13:36:12 UTC (rev 1564)
@@ -377,6 +377,7 @@
     open (IN, '<', $filename) or return $ret;
     my $i = 0;
     my $var = "0";
+    my $backgrounded = 0;
     local $_;
     while (<IN>) {
         chomp;
@@ -409,7 +410,26 @@
             last;
         } elsif (/^\s*(\w+)=\$0;/) {
            $var = $1;
+       } elsif (m~
+           # Match scripts which use "foo $0 $@ &\nexec true\n"
+           # Program name
+           \S+\s+
+
+           # As above
+           .?\$$var.?\s*
+           (--\s*)?
+           .?(\${1:?\+.?)?(\$(\@|\*))?.?\s*\&~x) {
+
+           $backgrounded = 1;
+       } elsif ($backgrounded and m~
+           # the exec should either be "eval"ed or a new statement
+           (^\s*|\beval\s*[\'\"]|(;|&&)\s*)
+           exec\s+true(\s|\Z)~x) {
+
+           $ret = $. - 1;
+           last;
        }
+
     }
     close IN;
     return $ret;



-- 
To unsubscribe, send mail to [EMAIL PROTECTED]

Reply via email to