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

[SCM] Debian package checker branch, master, updated. 2.0.0-13-g0094324



The following commit has been merged in the master branch:
commit ea977669d2c716acb83b395f9163b6341a15e15d
Author: Frank Lichtenheld <djpig@debian.org>
Date:   Sat Sep 13 22:36:39 2008 +0200

    Unify handling of known shell names
    
    Several places search for known shell names. As one can see in the
    code they diverged over time. Move the regex to common_data.pm to
    avoid that happening in the future.
    
    Also add mksh while at it.

diff --git a/checks/common_data.pm b/checks/common_data.pm
index 6d4dd20..6105b4e 100644
--- a/checks/common_data.pm
+++ b/checks/common_data.pm
@@ -13,6 +13,7 @@ our @EXPORT = qw
    %known_libpngs %known_x_metapackages
    %non_standard_archs %all_cpus %all_oses
    %known_doc_base_formats
+   $known_shells_regex
 );
 
 # To let "perl -cw" test know we use these variables;
@@ -26,6 +27,7 @@ use vars qw
   %known_libpngs %known_x_metapackages
   %all_cpus %all_oses
   %known_doc_base_formats
+  $known_shells_regex
 );
 
 # simple defines for commonly needed data
@@ -174,6 +176,8 @@ use vars qw
 %known_doc_base_formats = map { $_ => 1 }
     ( 'html', 'text', 'pdf', 'postscript', 'info', 'dvi', 'debiandoc-sgml' );
 
+$known_shells_regex = qr'(?:(?:b|d)?a|t?c|(?:pd|m)?k|z)?sh';
+
 1;
 
 # Local Variables:
diff --git a/checks/infofiles b/checks/infofiles
index 1f956c3..249b796 100644
--- a/checks/infofiles
+++ b/checks/infofiles
@@ -21,6 +21,10 @@
 
 package Lintian::infofiles;
 use strict;
+
+use lib "$ENV{'LINTIAN_ROOT'}/checks/";
+use common_data;
+
 use Tags;
 use Util;
 use File::Basename;
@@ -150,7 +154,7 @@ sub check_script {
 	fail("cannot open maintainer script control/$script for reading: $!");
     $interp = <IN>;
     $interp = '' unless defined $interp;
-    if ($interp =~ m,^\#\!\s*/bin/(a|ba|k|pdk)?sh,) {
+    if ($interp =~ m,^\#\!\s*/bin/$known_shells_regex,) {
 	$interp = 'sh';
     } elsif ($interp =~ m,^\#\!\s*/usr/bin/perl,) {
 	$interp = 'perl';
diff --git a/checks/menus b/checks/menus
index 228e4ba..9d4cb7c 100644
--- a/checks/menus
+++ b/checks/menus
@@ -22,6 +22,7 @@
 
 package Lintian::menus;
 use strict;
+
 use lib "$ENV{'LINTIAN_ROOT'}/checks/";
 use common_data;
 
@@ -579,7 +580,7 @@ sub check_script {
 	fail("cannot open maintainer script control/$script for reading: $!");
     $interp = <IN>;
     $interp = '' unless defined $interp;
-    if ($interp =~ m,^\#\!\s*/bin/(a|ba|k|pdk)?sh,) {
+    if ($interp =~ m,^\#\!\s*/bin/$known_shells_regex,) {
         $interp = 'sh';
     } elsif ($interp =~ m,^\#\!\s*/usr/bin/perl,) {
         $interp = 'perl';
diff --git a/checks/scripts b/checks/scripts
index 5e0f8de..37850bb 100644
--- a/checks/scripts
+++ b/checks/scripts
@@ -24,6 +24,9 @@
 
 package Lintian::scripts;
 use strict;
+
+use lib "$ENV{'LINTIAN_ROOT'}/checks/";
+use common_data;
 use Dep;
 use Tags;
 use Util;
@@ -276,13 +279,15 @@ for my $filename (sort keys %{$info->scripts}) {
     # Syntax-check most shell scripts, but don't syntax-check scripts that end
     # in .dpatch.  bash -n doesn't stop checking at exit 0 and goes on to blow
     # up on the patch itself.
-    # zsh -n is broken, see #485885
-    if ($base =~ /^(?:(?:b|d)?a|k)?sh$/) {
-	if (-x "$interpreter" && ! script_is_evil_and_wrong("unpacked/$filename")) {
-	    if ($filename !~ m,\.dpatch$,) {
-		if (check_script_syntax($interpreter, "unpacked/$filename")) {
-		    tag("shell-script-fails-syntax-check", $filename);
-		}
+    if ($base =~ /^$known_shells_regex$/) {
+	if (-x $interpreter
+	    and ! script_is_evil_and_wrong("unpacked/$filename")
+	    and $filename !~ m,\.dpatch$,
+	    # exclude some shells. zsh -n is broken, see #485885
+	    and $base !~ m/^(z|t?c)sh$/) {
+
+	    if (check_script_syntax($interpreter, "unpacked/$filename")) {
+		tag("shell-script-fails-syntax-check", $filename);
 	    }
 	}
     }
@@ -451,7 +456,7 @@ while (<SCRIPTS>) {
     tag("csh-considered-harmful", $filename)
 	if ($base eq 'csh' or $base eq 'tcsh');
 
-    my $shellscript = $base =~ /^((b|d)?a|t?c|(pd)?k)?sh$/ ? 1 : 0;
+    my $shellscript = $base =~ /^$known_shells_regex$/ ? 1 : 0;
 
     # Only syntax-check scripts we can check with bash.
     my $checkbashisms;
@@ -544,7 +549,8 @@ while (<SCRIPTS>) {
 		$cat_string = "";
 	    }
 	    my $within_another_shell = 0;
-	    if (m,(^|\s+)((/usr)?/bin/)?((b|d)?a|k|z|t?c)sh\s+-c\s*.+,) {
+	    if (m,(?:^|\s+)(?:(?:/usr)?/bin/)?($known_shells_regex)\s+-c\s*.+,
+		and $1 ne 'sh') {
 		$within_another_shell = 1;
 	    }
 	    # if cat_string is set, we are in a HERE document and need not
diff --git a/debian/changelog b/debian/changelog
index 9dc9cf8..ac06dbf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,18 @@
+lintian (2.1.0) unstable; urgency=low
+
+  * checks/common_data.pm:
+    + [FL] Knew variable $known_shells_regex which matches known shell
+      names.  This removes some synchronisation issues between the
+      different regexes in use.
+  * checks/infofiles:
+    + [FL] Use $known_shells_regex from common_data.
+  * checks/menus:
+    + [FL] Use $known_shells_regex from common_data.
+  * check/scripts:
+    + [FL] Use $known_shells_regex from common_data.
+
+ -- Frank Lichtenheld <djpig@debian.org>  Sun, 28 Sep 2008 10:35:47 +0200
+
 lintian (2.0.0) unstable; urgency=low
 
   The "and this is only the beginning" release.

-- 
Debian package checker


Reply to: