The following commit has been merged in the master branch:
commit 0f5472b56a7d181ec889039b6f7fc88552cd6960
Author: Raphael Geissert <[email protected]>
Date:   Sun Oct 21 13:17:04 2012 -0500

    checkbashisms: multiple fixes to heredoc handling for convoluted code
    
    Signed-off-by: Benjamin Drung <[email protected]>

diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index ecd64f1..8f9b19c 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -433,10 +433,23 @@ foreach my $filename (@ARGV) {
 
            # 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*(?:(?!<|'|")((?:[^\s;]+(?:(?<=\\)[\s;])?)+)|[\'\"](.*?)[\'\"])/)
 {
                $cat_indented = ($1 && $1 eq '-')? 1 : 0;
-               $cat_string = $2;
-               $cat_string = $3 if not defined $cat_string;
+               my $quoted = defined($3);
+               $cat_string = $quoted? $3 : $2;
+               unless ($quoted) {
+                   # Now strip backslashes. Keep the position of the
+                   # last match in a variable, as s/// resets it back
+                   # to undef, but we don't want that.
+                   my $pos = 0;
+                   pos($cat_string) = $pos;
+                   while ($cat_string =~ s/\G(.*?)\\/$1/) {
+                       # postition += length of match + the character
+                       # that followed the backslash:
+                       $pos += length($1)+1;
+                       pos($cat_string) = $pos;
+                   }
+               }
                $start_lines{'cat_string'} = $.;
             }
        }

-- 
Git repository for devscripts

_______________________________________________
devscripts-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/devscripts-devel

Reply via email to