Author: adam-guest
Date: 2008-03-21 00:18:32 +0000 (Fri, 21 Mar 2008)
New Revision: 1178

Modified:
   trunk/debian/changelog
   trunk/scripts/checkbashisms.pl
Log:
  + If more than one issue was found within a single line, output each
    rather than just the first

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-03-21 00:13:26 UTC (rev 1177)
+++ trunk/debian/changelog      2008-03-21 00:18:32 UTC (rev 1178)
@@ -13,6 +13,8 @@
     + Enhance quoted block detection to handle escaped quotes better
     + Enhance "shell script wrapper" detection to catch more ways of
       disguising a non shell script as one
+    + If more than one issue was found within a single line, output each
+      rather than just the first
   * debcommit:
     + Make the change to --release's behaviour introduced in the last
       upload optional. If -R / --release-use-changelog is used then

Modified: trunk/scripts/checkbashisms.pl
===================================================================
--- trunk/scripts/checkbashisms.pl      2008-03-21 00:13:26 UTC (rev 1177)
+++ trunk/scripts/checkbashisms.pl      2008-03-21 00:18:32 UTC (rev 1178)
@@ -288,50 +288,42 @@
                    $found = 1;
                    $match = $1;
                    $explanation = "sourced script with arguments";
+                   output_explanation($filename, $orig_line, $explanation);
                }
            }
 
-           unless ($found) {
-               # Remove "quoted quotes". They're likely to be inside
-               # another pair of quotes; we're not interested in
-               # them for their own sake and removing them makes finding
-               # the limits of the outer pair far easier.
-               $line =~ s/(^|[^\\\'\"])\"\'\"/$1/g;
-               $line =~ s/(^|[^\\\'\"])\'\"\'/$1/g;
+           # Remove "quoted quotes". They're likely to be inside
+           # another pair of quotes; we're not interested in
+           # them for their own sake and removing them makes finding
+           # the limits of the outer pair far easier.
+           $line =~ s/(^|[^\\\'\"])\"\'\"/$1/g;
+           $line =~ s/(^|[^\\\'\"])\'\"\'/$1/g;
 
-               # Ignore anything inside single quotes; it could be an
-               # argument to grep or the like.
-               $line =~ s/(^|[^\\](?:\\\\)*)\'(?:\\.|[^\\\'])+\'/$1''/g;
+           # Ignore anything inside single quotes; it could be an
+           # argument to grep or the like.
+           $line =~ s/(^|[^\\](?:\\\\)*)\'(?:\\.|[^\\\'])+\'/$1''/g;
 
-               while (my ($re,$expl) = each %string_bashisms) {
-                   if ($line =~ m/($re)/) {
-                       $found = 1;
-                       $match = $1;
-                       $explanation = $expl;
-                       last;
-                   }
+           while (my ($re,$expl) = each %string_bashisms) {
+               if ($line =~ m/($re)/) {
+                   $found = 1;
+                   $match = $1;
+                   $explanation = $expl;
+                   output_explanation($filename, $orig_line, $explanation);
                }
            }
 
            # We've checked for all the things we still want to notice in
            # double-quoted strings, so now remove those strings as well.
-           unless ($found) {
-               $line =~ s/(^|[^\\](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g;
-               while (my ($re,$expl) = each %bashisms) {
-                   if ($line =~ m/($re)/) {
-                       $found = 1;
-                       $match = $1;
-                       $explanation = $expl;
-                       last;
-                   }
+           $line =~ s/(^|[^\\](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g;
+           while (my ($re,$expl) = each %bashisms) {
+               if ($line =~ m/($re)/) {
+                   $found = 1;
+                   $match = $1;
+                   $explanation = $expl;
+                   output_explanation($filename, $orig_line, $explanation);
                }
            }
 
-           unless ($found == 0) {
-               warn "possible bashism in $filename line $. 
($explanation):\n$orig_line\n";
-               $status |= 1;
-           }
-
            # Only look for the beginning of a heredoc here, after we've
            # stripped out quoted material, to avoid false positives.
            if (m/(?:^|[^<])\<\<\s*[\'\"]?\\?(\w+)[\'\"]?/) {
@@ -345,6 +337,13 @@
 
 exit $status;
 
+sub output_explanation {
+    my ($filename, $line, $explanation) = @_;
+
+    warn "possible bashism in $filename line $. ($explanation):\n$line\n";
+    $status |= 1;
+}
+
 # Returns non-zero if the given file is not actually a shell script,
 # just looks like one.
 sub script_is_evil_and_wrong {



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

Reply via email to