From 7b3a3bbe565fa531d8c9abca6684fd8c6154cceb Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 11 Jun 2014 00:56:32 +0200 Subject: [PATCH] apps/scan.pl: new argument parser, skip directories Directories inside inbound are now skipped. Instead of "scan.pl path/", now needs to be called with "scan.pl -i path/". This allows "-c config -i path". --- apps/scan.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/scan.pl b/apps/scan.pl index 3359852..0ce3682 100755 --- a/apps/scan.pl +++ b/apps/scan.pl @@ -20,13 +20,16 @@ sub handle_mail($); # handles single mail sub main() { - if(!$ARGV[0]) { - say "Usage: $0 "; + # parse argument list + my ($argidx) = grep { $ARGV[$_] eq '-i' } 0..$#ARGV; + if(!defined $argidx || !$ARGV[$argidx+1]) { + say "Usage: $0 <-i inbound>"; say "\tinbound: path to binkley-style inbound"; return(1); } + my $inbound = $ARGV[$argidx+1]; - my $fails = dispatch($ARGV[0]); + my $fails = dispatch($inbound); say "Finished with $fails errors."; # close areas @@ -53,6 +56,7 @@ sub dispatch($) opendir(my $dh, $dirname) or die("Can't open $dirname: $!"); while(my $file = readdir $dh) { next if($file =~ /^\.{1,2}$/); + next if(-d "$dirname/$file"); if($file =~ /^[0-9a-f]{8}\.(mo|tu|we|th|fr|sa|su)[0-9a-z]$/i) { # ARCMAIL bundle - assume ZIP -- 2.30.2