chiark / gitweb /
grep-excuses: --debug option
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Feb 2015 13:20:45 +0000 (13:20 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Feb 2015 15:33:37 +0000 (15:33 +0000)
For now this just shows the URL we fetch.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
scripts/grep-excuses.1
scripts/grep-excuses.pl

index 4d603a5b20368575046d4701f59e29c654f8b398..bb115e3acba696c3005d463470a4041c3c3db967 100644 (file)
@@ -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
index 67f0b6f8525ddd82c92cf91e9bb800716c025ab6..6a49935cc207d5227fac0efea0e06f7854fbb1d4 100755 (executable)
@@ -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$/) {
@@ -179,6 +186,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";