Author: adam-guest
Date: 2008-05-11 19:16:27 +0000 (Sun, 11 May 2008)
New Revision: 1441
Modified:
trunk/debian/changelog
trunk/scripts/checkbashisms.pl
Log:
+ Apply various improvements to "quoted block" detection
+ Correctly match 'echo "$(< $0)"'
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2008-05-11 13:09:43 UTC (rev 1440)
+++ trunk/debian/changelog 2008-05-11 19:16:27 UTC (rev 1441)
@@ -14,6 +14,8 @@
+ Further improve the heredoc detection (to allow the space in "<< 'foo'")
+ Make the check for "process substitution" ignore quoted strings
+ Don't flag "time)" as matching "time"
+ + Apply various improvements to "quoted block" detection
+ + Correctly match 'echo "$(< $0)"'
* cowpoke: New script to upload a Debian source package to a cowbuilder host
and build it, optionally also signing and uploading the result to an
incoming queue (Closes: #479274)
Modified: trunk/scripts/checkbashisms.pl
===================================================================
--- trunk/scripts/checkbashisms.pl 2008-05-11 13:09:43 UTC (rev 1440)
+++ trunk/scripts/checkbashisms.pl 2008-05-11 19:16:27 UTC (rev 1441)
@@ -195,10 +195,15 @@
my $explanation = '';
my $line = $_;
+ # Remove "" / '' as they clearly aren't quoted strings
+ # and not considering them makes the matching easier
+ $line =~ s/(^|[^\\])(\'\')/$1/g;
+ $line =~ s/(^|[^\\])(\"\")/$1/g;
+
if ($quote_string ne "") {
my $otherquote = ($quote_string eq "\"" ? "\'" : "\"");
# Inside a quoted block
- if ($line =~ /(?:^|^.*?[^\\$otherquote])$quote_string(.*)$/) {
+ if ($line =~ /(?:^|^.*[^\\$otherquote])$quote_string(.*)$/) {
my $rest = $1;
my $templine = $line;
@@ -206,8 +211,6 @@
$templine =~
s/[^\\]$otherquote[^$quote_string]*?[^\\]$otherquote//g;
# Remove quotes that are themselves quoted
$templine =~
s/[^\\]$otherquote.*?$quote_string.*?[^\\]$otherquote//g;
- # Remove "" or ''
- $templine =~ s/(^|[^\\])$quote_string$quote_string/$1/g;
# After all that, were there still any quotes left?
my $count = () = $templine =~ /(^|[^\\])$quote_string/g;
@@ -242,13 +245,9 @@
my $otherquote = ($quote eq "\"" ? "\'" : "\"");
# Remove balanced quotes and their content
- $templine =~
s/(^|[^\\](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g;
- $templine =~
s/(^|[^\\](?:\\\\)*)\'(?:\\.|[^\\\'])+\'/$1''/g;
+ $templine =~ s/(^|[^\\](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1/g;
+ $templine =~ s/(^|[^\\](?:\\\\)*)\'(?:\\.|[^\\\'])+\'/$1/g;
- # Remove "" / '' as they clearly aren't quoted strings
- # and not considering them makes the matching easier
- $templine =~ s/(^|[^\\])($quote$quote)/$1/g;
-
# Don't flag quotes that are themselves quoted
$templine =~ s/$otherquote.*?$quote.*?$otherquote//g;
my $count = () = $templine =~ /(^|[^\\])$quote/g;
@@ -447,11 +446,11 @@
}
if ($makefile) {
- $bashisms{'(\$\(|\`)\s*\<\s*([^\s\)]{2,}|[^DF])\s*(\)|\`)'} =
+ $string_bashisms{'(\$\(|\`)\s*\<\s*([^\s\)]{2,}|[^DF])\s*(\)|\`)'} =
q<'$(\< foo)' should be '$(cat foo)'>;
} else {
$bashisms{'(?:^|\s+)\w+\+='} = q<should be VAR="${VAR}foo">;
- $bashisms{'(\$\(|\`)\s*\<\s*\S+\s*(\)|\`)'} = q<'$(\< foo)' should be
'$(cat foo)'>;
+ $string_bashisms{'(\$\(|\`)\s*\<\s*\S+\s*(\)|\`)'} = q<'$(\< foo)'
should be '$(cat foo)'>;
}
if ($opt_extra) {
--
To unsubscribe, send mail to [EMAIL PROTECTED]