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

[SCM] Debian package checker branch, master, updated. 2.2.2-17-g37433b1



The following commit has been merged in the master branch:
commit 37433b1e6396c57afb1e6dcbf467fec92a11d38e
Author: Russ Allbery <rra@debian.org>
Date:   Fri Feb 6 23:10:06 2009 -0800

    Add check for #!/bin/sh -e instead of set -e
    
    * checks/scripts{,.desc}:
      + [RA] Add pedantic check for maintainer scripts using #!/bin/sh -e
        instead of set -e in the script body.  (Closes: #119045)

diff --git a/checks/scripts b/checks/scripts
index c0f9e85..692ae95 100644
--- a/checks/scripts
+++ b/checks/scripts
@@ -530,13 +530,13 @@ while (<SCRIPTS>) {
 	or fail("cannot open maintainer script $filename for reading: $!");
 
     my %warned;
-    my ($saw_init, $saw_invoke, $saw_debconf, $saw_sete, $has_code);
+    my ($saw_init, $saw_invoke, $saw_debconf, $saw_bange, $saw_sete, $has_code);
     my $cat_string = "";
 
     my $previous_line = "";
     while (<C>) {
 	if ($. == 1 && $shellscript && m,/$base\s*.*\s-\w*e\w*\b,) {
-	    $saw_sete = 1;
+	    $saw_bange = 1;
 	}
 
 	next if m,^\s*$,;  # skip empty lines
@@ -882,7 +882,11 @@ while (<SCRIPTS>) {
 	tag "maintainer-script-empty", $file;
     }
     if ($shellscript && !$saw_sete) {
-	tag 'maintainer-script-ignores-errors', $file;
+	if ($saw_bange) {
+	    tag 'maintainer-script-without-set-e', $file;
+	} else {
+	    tag 'maintainer-script-ignores-errors', $file;
+	}
     }
 
     close C;
diff --git a/checks/scripts.desc b/checks/scripts.desc
index 7b2fb3b..96a5bfe 100644
--- a/checks/scripts.desc
+++ b/checks/scripts.desc
@@ -498,11 +498,22 @@ Info: The maintainer script doesn't seem to contain any code other than
 Tag: maintainer-script-ignores-errors
 Severity: normal
 Certainty: certain
-Ref: policy 3.9
+Ref: policy 10.4
 Info: The maintainer script doesn't seem to set the <tt>-e</tt> flag which
  ensures that the script's execution is aborted when any executed command
  fails.
 
+Tag: maintainer-script-without-set-e
+Severity: pedantic
+Certainty: certain
+Ref: policy 10.4
+Info: The maintainer script passes <tt>-e</tt> to the shell on the
+ <tt>#!</tt> line rather than using <tt>set -e</tt> in the body of the
+ script.  This is fine for normal operation, but if the script is run by
+ hand with <tt>sh /path/to/script</tt> (common in debugging), <tt>-e</tt>
+ will not be in effect.  It's therefore better to use <tt>set -e</tt> in
+ the body of the script.
+
 Tag: command-with-path-in-maintainer-script
 Severity: normal
 Certainty: certain
diff --git a/debian/changelog b/debian/changelog
index 5bb7958..5d32301 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,7 @@ lintian (2.2.3) UNRELEASED; urgency=low
       - dfsg-version-misspelled
       - experimental-to-unstable-without-comment (pedantic)
       - homepage-for-cpan-package-contains-version
+      - maintainer-script-without-set-e (pedantic)
       - using-first-person-in-description
     + Removed
       - non-us-spelling
@@ -48,6 +49,9 @@ lintian (2.2.3) UNRELEASED; urgency=low
   * checks/files:
     + [ADB] Don't report duplicate-font-file for udebs.  Patch by Raphael
       Geissert.  (Closes: #514095)
+  * checks/scripts{,.desc}:
+    + [RA] Add pedantic check for maintainer scripts using #!/bin/sh -e
+      instead of set -e in the script body.  (Closes: #119045)
 
   * lib/Spelling.pm:
     + [RA] Add some additional typo and case corrections.  Patch from
diff --git a/t/tests/scripts-maintainer-script-set-e/debian/debian/postinst b/t/tests/scripts-maintainer-script-set-e/debian/debian/postinst
new file mode 100644
index 0000000..dc11a43
--- /dev/null
+++ b/t/tests/scripts-maintainer-script-set-e/debian/debian/postinst
@@ -0,0 +1,9 @@
+#!/bin/sh -e
+
+if [ "$1" = configure ] ; then
+    frobnicate something
+fi
+
+#DEBHELPER#
+
+exit 0
diff --git a/t/tests/scripts-maintainer-script-set-e/desc b/t/tests/scripts-maintainer-script-set-e/desc
new file mode 100644
index 0000000..c652e3a
--- /dev/null
+++ b/t/tests/scripts-maintainer-script-set-e/desc
@@ -0,0 +1,7 @@
+Testname: scripts-maintainer-script-set-e
+Sequence: 6000
+Version: 1.0
+Description: Test for using set -e in script body
+Skeleton: pedantic
+Options: --pedantic -I -E
+Test-For: maintainer-script-without-set-e
diff --git a/t/tests/scripts-maintainer-script-set-e/tags b/t/tests/scripts-maintainer-script-set-e/tags
new file mode 100644
index 0000000..337ad65
--- /dev/null
+++ b/t/tests/scripts-maintainer-script-set-e/tags
@@ -0,0 +1 @@
+P: scripts-maintainer-script-set-e: maintainer-script-without-set-e postinst

-- 
Debian package checker


Reply to: