Bug#777345: grep-excuses: Provide --debug option

Ian Jackson ijackson at chiark.greenend.org.uk
Sat Feb 7 15:42:12 UTC 2015


Package: devscripts
Version: 2.15.1
Severity: wishlist
Tags: patch

The patch below is also available in this dgit-history-based git
branch:
  git://git.chiark.greenend.org.uk/~ianmdlvl/devscripts.git#dgit/sid
  http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=devscripts.git;a=log;h=refs/heads/dgit/sid

I have not included here any updates to debian/changelog.

Thanks,
Ian.

>From 6f46be40f505a56adafb38f0dc9c29b8c72f3fbc Mon Sep 17 00:00:00 2001
From: Ian Jackson <ijackson at chiark.greenend.org.uk>
Date: Sat, 7 Feb 2015 13:20:45 +0000
Subject: [PATCH 2/3] grep-excuses: --debug option

For now this just shows the URL we fetch.

Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
 scripts/grep-excuses.1  |    3 +++
 scripts/grep-excuses.pl |    9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/scripts/grep-excuses.1 b/scripts/grep-excuses.1
index 38767e9..b911a9f 100644
--- a/scripts/grep-excuses.1
+++ b/scripts/grep-excuses.1
@@ -25,6 +25,9 @@ Show a brief usage message.
 .TP
 .B \-\-version
 Show version and copyright information.
+.TP
+.B \-\-debug
+Print debugging output to stderr (including url(s) fetched).
 .SH "CONFIGURATION VARIABLES"
 The two configuration files \fI/etc/devscripts.conf\fR and
 \fI~/.devscripts\fR are sourced in that order to set configuration
diff --git a/scripts/grep-excuses.pl b/scripts/grep-excuses.pl
index d1dd756..069d23f 100755
--- a/scripts/grep-excuses.pl
+++ b/scripts/grep-excuses.pl
@@ -24,6 +24,8 @@ use File::Basename;
 
 # Needed for --wipnity option
 
+open DEBUG, ">/dev/null" or die $!;
+
 my $term_size_broken;
 
 sub have_term_size {
@@ -67,6 +69,7 @@ Options:
                       name must be given when using this option.
   --help              Show this help
   --version           Give version information
+  --debug             Print debugging output to stderr
 
 Default settings modified by devscripts configuration files:
 $modified_conf_msg
@@ -150,6 +153,10 @@ while (@ARGV and $ARGV[0] =~ /^-/) {
 	    die "$progname: too many arguments!  Try $progname --help for help.\n";
 	} else { wipnity($string); exit 0; }
     }
+    if ($ARGV[0] eq '--debug') {
+	open DEBUG, ">&STDERR" or die $!;
+	shift; next;
+    }
     if ($ARGV[0] eq '--help') { usage(); exit 0; }
     if ($ARGV[0] eq '--version') { print $version; exit 0; }
     if ($ARGV[0] =~ /^--no-?conf$/) {
@@ -176,6 +183,8 @@ if (system("command -v wget >/dev/null 2>&1") != 0) {
     die "$progname: this program requires the wget package to be installed\n";
 }
 
+print DEBUG "Fetching $url\n";
+
 open EXCUSES, "wget -q -O - $url | zcat |" or
     die "$progname: wget | zcat failed: $!\n";
 
-- 
1.7.10.4



-- 
Ian Jackson                  personal email: <ijackson at chiark.greenend.org.uk>
These opinions are my own.        http://www.chiark.greenend.org.uk/~ijackson/



More information about the devscripts-devel mailing list