# HG changeset patch # User heiko # Date 1167819474 0 # Node ID de6564667c1bcaac3e0369360092e420c2764e35 # Parent 93551b0dbeeea99eb8a579e13f097a79dbd134f4 wildcards diff -r 93551b0dbeee -r de6564667c1b debian/cron.daily --- a/debian/cron.daily Wed Jan 03 09:36:10 2007 +0000 +++ b/debian/cron.daily Wed Jan 03 10:17:54 2007 +0000 @@ -1,2 +1,2 @@ #! /bin/bash -exigrey --clean 3 `exigrey --dbs` >/dev/null +exigrey --clean 3 '*' diff -r 93551b0dbeee -r de6564667c1b exigrey.pl --- a/exigrey.pl Wed Jan 03 09:36:10 2007 +0000 +++ b/exigrey.pl Wed Jan 03 10:17:54 2007 +0000 @@ -10,7 +10,7 @@ !ME! --list [db] # list all items !ME! --stat [db ...] # print short statistic !ME! --clean [days [db ...]] # remove items not used since days - !ME! --dbs # list dbm files in default directory + !ME! --dbs [glob] # list dbm files in default directory Defaults: delay: !$DEFAULT{delay}! db: !$DEFAULT{db}! @@ -39,6 +39,7 @@ my $opt_clean; my $opt_dbs; +sub getDBs($); sub iterate(\%$); MAIN: { @@ -72,7 +73,9 @@ } if ($opt_stats) { - foreach ((@ARGV ? @ARGV : $DEFAULT{db})) { + @ARGV = ($DEFAULT{db}) unless @ARGV; + @ARGV = getDBs($ARGV[0]) if $ARGV[0] =~ /[\*\?]/; + foreach (@ARGV) { my %h; my $db = connectDB(\%h, $_); @@ -107,6 +110,8 @@ if ($opt_clean) { my $cut = time() - (86400 * (@ARGV ? shift : 7)); + @ARGV = ($DEFAULT{db}) unless @ARGV; + @ARGV = getDBs($ARGV[0]) if $ARGV[0] =~ /[\*\?]/; foreach (@ARGV ? @ARGV : $DEFAULT{db}) { my %h; my $tmp = tmpfile(); @@ -126,7 +131,7 @@ } if ($opt_dbs) { - print join("\n", glob(getDBDir() . "/*")), "\n"; + print join("\n", getDBs(shift || "*")), "\n"; exit 0; } @@ -136,6 +141,10 @@ } } +sub getDBs($) { + glob(getDBDir() . "/$_[0]"); +} + # Helper to iterate over our hash and call the passed # "callback" function (item, v0, v1, delta) sub iterate(\%$) {