From: Ian Jackson Date: Wed, 19 Aug 2020 20:53:50 +0000 (+0100) Subject: expire-8601: wip new version X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=7b2e2c91dd4675f39ebf46d5b16be4bb17b4929e;hp=4bf97c5f3237b9fc7a344e2bc9101539012963e9;p=chiark-utils.git expire-8601: wip new version Signed-off-by: Ian Jackson --- diff --git a/scripts/expire-iso8601.new b/scripts/expire-iso8601.new index f001b35..e3a8836 100755 --- a/scripts/expire-iso8601.new +++ b/scripts/expire-iso8601.new @@ -55,6 +55,7 @@ our $rm = 1; our $recurse = 1; our $unit = 86400; our $slop; +our $debug; our @intervals; sub badusage ($) { @@ -98,7 +99,7 @@ sub precomp () { $_->{A} = ($newest_t - $_->{T}) / $unit foreach @files; $slop /= $unit; -# print DEBUG Dumper(\@files, \@intervals); + print DEBUG Dumper(\@files, \@intervals) if $debug >= 2; } sub flag ($) { @@ -166,7 +167,7 @@ while (@ARGV && $ARGV[0] =~ m/^-/) { while (m/^-./) { if (s/^-n/-/) { $rm=0; } elsif (s/-r/-/) { $recurse=1; } - elsif (s/-D/-/) { open DEBUG, ">&STDERR" or die $!; DEBUG->autoflush(1) } + elsif (s/-D/-/) { $debug++; } elsif (s/-u(\d+)$//) { $unit=$1; } elsif (s/-s(\d+)$//) { $slop=$1; } else { badusage "unknown short option $_" } @@ -181,6 +182,11 @@ while (@ARGV && $ARGV[0] =~ m/^-/) { badusage "too few arguments" unless @ARGV; +if ($debug) { + open DEBUG, ">&STDERR" or die $!; + DEBUG->autoflush(1); +} + $slop //= $unit * 0.1; foreach (@ARGV) {