Author: adam-guest
Date: 2008-05-30 21:36:42 +0000 (Fri, 30 May 2008)
New Revision: 1463

Modified:
   trunk/debian/changelog
   trunk/scripts/checkbashisms.pl
Log:
* checkbashisms:
  + Don't treat scripts with dash or ash shebangs as "/bin/sh scripts", as
    dash implements some extensions to POSIX
  + Correctly match heredocs using "<<-"

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-05-27 20:11:44 UTC (rev 1462)
+++ trunk/debian/changelog      2008-05-30 21:36:42 UTC (rev 1463)
@@ -1,7 +1,10 @@
 devscripts (2.10.29) UNRELEASED; urgency=low
 
-  * checkbashisms: Add checks for "sh -r", "sh -D", "sh [-+]O" and "sh with
-    long options"
+  * checkbashisms:
+    + Add checks for "sh -r", "sh -D", "sh [-+]O" and "sh with long options"
+    + Don't treat scripts with dash or ash shebangs as "/bin/sh scripts", as
+      dash implements some extensions to POSIX
+    + Correctly match heredocs using "<<-"
   * debdiff: Don't apply patches when extracting a Format 3.0 (quilt) source
     package, to minimise noise in the diffs (Closes: #475506)
   * getbuildlog: New script from Frank S. Thomas to download build logs for

Modified: trunk/scripts/checkbashisms.pl
===================================================================
--- trunk/scripts/checkbashisms.pl      2008-05-27 20:11:44 UTC (rev 1462)
+++ trunk/scripts/checkbashisms.pl      2008-05-30 21:36:42 UTC (rev 1463)
@@ -123,7 +123,7 @@
                    $status |= 2;
                    last;  # end this file
                }
-               elsif ($interpreter !~ m,/(sh|ash|dash|posh)$,) {
+               elsif ($interpreter !~ m,/(sh|posh)$,) {
 ### ksh/zsh?
                    warn "script $filename does not appear to be a /bin/sh 
script; skipping\n";
                    $status |= 2;
@@ -285,7 +285,7 @@
            # spaces between << and the delimeter to make the following
            # updates to $cat_line easier.
            my $cat_line = $line;
-           $cat_line =~ s/(<\<)\s+/$1/g;
+           $cat_line =~ s/(<\<-?)\s+/$1/g;
 
            # Ignore anything inside single quotes; it could be an
            # argument to grep or the like.
@@ -293,7 +293,10 @@
            # As above, with the exception that we don't remove the string
            # if the quote is immediately preceeded by a <, so we
            # can match "foo <<'xyz'" as a heredoc later
-           $cat_line =~ s/(^|[^<\\](?:\\\\)*)\'(?:\\.|[^\\\'])+\'/$1''/g;
+           while ($cat_line =~ m/(^|[^<\\](-?)(\\\\)*)\'(\\.|[^\\\'])+\'/gc) {
+               $cat_line =~ s/(^|[^<\\](-?)(\\\\)*)\'(\\.|[^\\\'])+\'/$1''/
+                   unless defined $2;
+           }
 
            while (my ($re,$expl) = each %string_bashisms) {
                if ($line =~ m/($re)/) {
@@ -307,7 +310,10 @@
            # We've checked for all the things we still want to notice in
            # double-quoted strings, so now remove those strings as well.
            $line =~ s/(^|[^\\](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g;
-           $cat_line =~ s/(^|[^<\\](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g;
+           while ($cat_line =~ m/(^|[^<\\](-?)(\\\\)*)\"(\\.|[^\\\"])+\"/gc) {
+               $cat_line =~ s/(^|[^<\\](-?)(\\\\)*)\"(\\.|[^\\\"])+\"/$1""/
+                   unless defined $2;
+           }
            while (my ($re,$expl) = each %bashisms) {
                if ($line =~ m/($re)/) {
                    $found = 1;
@@ -319,7 +325,7 @@
 
            # Only look for the beginning of a heredoc here, after we've
            # stripped out quoted material, to avoid false positives.
-           if ($cat_line =~ 
m/(?:^|[^<])\<\<\s*(?:[\\]?(\w+)|[\'\"](.*?)[\'\"])/) {
+           if ($cat_line =~ 
m/(?:^|[^<])\<\<\-?s*(?:[\\]?(\w+)|[\'\"](.*?)[\'\"])/) {
                $cat_string = $1;
                $cat_string = $2 if not defined $cat_string;
             }



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

Reply via email to