[debhelper-devel] [debhelper] 01/01: Dh_Getopt: Fix discard of warning/error messages in option parsing

Niels Thykier nthykier at moszumanska.debian.org
Tue Sep 26 18:29:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit fa8e36543c863f9c5a70a7abfcbc7f22262e92c0
Author: Niels Thykier <niels at thykier.net>
Date:   Tue Sep 26 18:17:53 2017 +0000

    Dh_Getopt: Fix discard of warning/error messages in option parsing
    
    When testing -O options, the __WARN__ handler would be set to a sub to
    throw away warnings for -O options.  However, the original __WARN__
    handler would not be properly reset in the case where it was
    originally "undef" (which happens to be the default).  This triggered
    a discard of real error messages in case there was a later call to
    "getoptions".
    
    Concretely, this was trivially reproducible via:
    
      DH_OPTIONS=-Oa dh_makeshlibs -ppackage-that-does-not-exist
    
    This /should/ have failed with:
    
      dh_makeshlibs: Requested unknown package foo via -p/--package, expected one of: [...]
      dh_makeshlibs: unknown option or error during option parsing; aborting
    
    But prior to this commit, only the latter line would appear.  This
    sadly makes the error rather hard to understand.
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog                  | 4 ++++
 lib/Debian/Debhelper/Dh_Getopt.pm | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 564fbe3..590186c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,10 @@
 debhelper (10.9.1) UNRELEASED; urgency=medium
 
   * dh_builddeb: Add some missing error checks.
+  * Dh_Lib.pm: Fix bug where debhelper could shallow some error
+    messages during parsing when -O options were passed via
+    DH_OPTIONS (among other).  Thanks to Adrian Bunk and
+    Andrew Shadura for reporting the issue.  (Closes: #876689)
 
  -- Niels Thykier <niels at thykier.net>  Thu, 21 Sep 2017 19:13:19 +0000
 
diff --git a/lib/Debian/Debhelper/Dh_Getopt.pm b/lib/Debian/Debhelper/Dh_Getopt.pm
index 10da2df..dce0bca 100644
--- a/lib/Debian/Debhelper/Dh_Getopt.pm
+++ b/lib/Debian/Debhelper/Dh_Getopt.pm
@@ -174,7 +174,7 @@ sub getoptions {
 		$SIG{__WARN__}=sub {};
 	}
 	my $ret=Getopt::Long::GetOptionsFromArray($array, %options);
-	if ($oldwarn) {
+	if ($params{test} || $params{ignore_unknown_options}) {
 		$SIG{__WARN__}=$oldwarn;
 	}
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list