[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

lintian: r1110 - in trunk: checks debian testset testset/maintainer-scripts/debian



Author: rra
Date: 2008-01-05 00:55:19 +0100 (Sat, 05 Jan 2008)
New Revision: 1110

Modified:
   trunk/checks/scripts
   trunk/debian/changelog
   trunk/testset/maintainer-scripts/debian/postinst
   trunk/testset/tags.maintainer-scripts
Log:
  + [RA] Improve recognition of heredocs.
  + [RA] Recognize quoted strings that start at beginning of the line.

Modified: trunk/checks/scripts
===================================================================
--- trunk/checks/scripts	2008-01-04 06:03:51 UTC (rev 1109)
+++ trunk/checks/scripts	2008-01-04 23:55:19 UTC (rev 1110)
@@ -512,20 +512,13 @@
 	}
 
 	if ($shellscript) {
-	    if (m/^\s*cat\s*\<\<\s*(\w+)/) {
-		$cat_string = $1;
-	    }
-	    elsif ($cat_string ne "" and m/^$cat_string/) {
+	    if ($cat_string ne "" and m/^$cat_string/) {
 		$cat_string = "";
 	    }
 	    my $within_another_shell = 0;
 	    if (m,(^|\s+)((/usr)?/bin/)?((b|d)?a|k|z|t?c)sh\s+-c\s*.+,) {
 		$within_another_shell = 1;
 	    }
-	    #Don't use chown foo.bar:
-	    if (m{(chown\s+[-_A-Za-z0-9]+\.[-_A-Za-z0-9]+)\s+}) {
-	    	tag "deprecated-chown-usage", "$file:$. \'$1\'";
-	    }
 	    # if cat_string is set, we are in a HERE document and need not
 	    # check for things
 	    if ($cat_string eq "" and $checkbashisms and !$within_another_shell) {
@@ -566,8 +559,8 @@
 
 		# Ignore anything inside single quotes; it could be an
 		# argument to grep or the like.
-                my $line = $_;
-		$line =~ s/([^\\](?:\\\\)*)\'(?:\\.|[^\\\'])+\'/$1''/g;
+		my $line = $_;
+		$line =~ s/(^|[^\\](?:\\\\)*)\'(?:\\.|[^\\\'])+\'/$1''/g;
 
 		for my $re (@bashism_string_regexs) {
 		    if ($line =~ m/($re)/) {
@@ -580,7 +573,7 @@
 		# 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;
+		    $line =~ s/(^|[^\\](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g;
 		    for my $re (@bashism_regexs) {
 			if ($line =~ m/($re)/) {
 			    $found = 1;
@@ -593,8 +586,18 @@
 		if ($found) {
 		    tag "possible-bashism-in-maintainer-script", "$file:$. \'$match\'";
 		}
+
+		# Only look for the beginning of a heredoc here, after we've
+		# stripped out quoted material, to avoid false positives.
+		if (m/\<\<\s*[\'\"]?(\w+)[\'\"]?/) {
+		    $cat_string = $1;
+		}
 	    }
 	    if (!$cat_string) {
+		# Don't use chown foo.bar
+		if (/(chown\s+[-_A-Za-z0-9]+\.[-_A-Za-z0-9]+)\s+/) {
+		    tag "deprecated-chown-usage", "$file:$. \'$1\'";
+		}
 		if (/invoke-rc.d.*\|\| exit 0/) {
 		    tag "maintainer-script-hides-init-failure", "$file:$.";
 		}

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2008-01-04 06:03:51 UTC (rev 1109)
+++ trunk/debian/changelog	2008-01-04 23:55:19 UTC (rev 1110)
@@ -63,6 +63,8 @@
       of 00list.  Patch by Chris Lamb.  (Closes: #457523)
   * checks/scripts:
     + [RA] Add lua40 and lua5.1.  Thanks, Enrico Tassi.  (Closes: #457219)
+    + [RA] Improve recognition of heredocs.
+    + [RA] Recognize quoted strings that start at beginning of the line.
   * checks/shared-libs{.desc,}:
     + [RA] New check for version numbers in symbol files.  Based on a
       patch from Raphael Hertzog.  (Closes: #457067)

Modified: trunk/testset/maintainer-scripts/debian/postinst
===================================================================
--- trunk/testset/maintainer-scripts/debian/postinst	2008-01-04 06:03:51 UTC (rev 1109)
+++ trunk/testset/maintainer-scripts/debian/postinst	2008-01-04 23:55:19 UTC (rev 1110)
@@ -97,3 +97,17 @@
 # Deprecated and not allowed except the second one.
 install-sgmlcatalog --install package
 install-sgmlcatalog --remove package
+
+# This too is a heredoc.
+some-program > /etc/config-file <<'EOF'
+echo "All of the array is: ${H[@]}"
+EOF
+
+# But this isn't.
+cat '>>EOF'
+echo "All of the array is: ${H[@]}"
+EOF
+
+# Recognize single quotes even if they start at the beginning of a line.
+echo not a bashism \
+'/{ptex,tex}/{amstex,plain,generic,}'

Modified: trunk/testset/tags.maintainer-scripts
===================================================================
--- trunk/testset/tags.maintainer-scripts	2008-01-04 06:03:51 UTC (rev 1109)
+++ trunk/testset/tags.maintainer-scripts	2008-01-04 23:55:19 UTC (rev 1110)
@@ -42,6 +42,7 @@
 W: maintainer-scripts: maintainer-script-needs-depends-on-xml-core postinst
 W: maintainer-scripts: missing-debconf-dependency
 W: maintainer-scripts: no-debconf-templates
+W: maintainer-scripts: possible-bashism-in-maintainer-script postinst:108 '${H[@]}'
 W: maintainer-scripts: possible-bashism-in-maintainer-script postinst:15 '. /usr/share/lintian/shell foo'
 W: maintainer-scripts: possible-bashism-in-maintainer-script postinst:18 'read'
 W: maintainer-scripts: possible-bashism-in-maintainer-script postinst:20 'H[0]='


Reply to: