The following commit has been merged in the master branch:
commit aabe1f92ae892dc6666256600666da0cf80c5797
Author: Raphael Geissert <[email protected]>
Date:   Tue May 25 00:45:52 2010 -0500

    checkbashisms: fix multiple quotes-handling bugs
    
    Signed-off-by: Raphael Geissert <[email protected]>
    Signed-off-by: James Vega <[email protected]>

diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index 65800eb..8cec53d 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -156,7 +156,10 @@ foreach my $filename (@ARGV) {
        # will be treated as part of the comment.
        # s/^(?:.*?[^\\])?$quote_string(.*)$/$1/ if $quote_string ne "";
 
-       next if m,^\s*\#,;  # skip comment lines
+       # skip comment lines
+       if (m,^\s*\#, && $quote_string eq '' && $buffered_line eq '' && 
$cat_string eq '') {
+           next;
+       }
 
        # Remove quoted strings so we can more easily ignore comments
        # inside them
@@ -278,7 +281,7 @@ foreach my $filename (@ARGV) {
                    my $otherquote = ($quote eq "\"" ? "\'" : "\"");
 
                    # Remove balanced quotes and their content
-                   $templine =~ 
s/(^|[^\\\"](?:\\\\)*)\'(?:\\.|[^\\\'])+\'/$1/g;
+                   $templine =~ s/(^|[^\\\"](?:\\\\)*)\'[^\']*\'/$1/g;
                    $templine =~ 
s/(^|[^\\\'](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1/g;
 
                    # Don't flag quotes that are themselves quoted
@@ -286,6 +289,8 @@ foreach my $filename (@ARGV) {
                    $templine =~ s/$otherquote.*?$quote.*?$otherquote//g;
                    # "\""
                    $templine =~ s/(^|[^\\])$quote\\$quote$quote/$1/g;
+                   # \' or \"
+                   $templine =~ s/\\[\'\"]//g;
                    my $count = () = $templine =~ /(^|(?!\\))$quote/g;
 
                    # If there's an odd number of non-escaped
@@ -397,7 +402,6 @@ foreach my $filename (@ARGV) {
             }
        }
     }
-
     close C;
 }
 

-- 
Git repository for devscripts


-- 
To unsubscribe, send mail to [email protected].

Reply via email to