From e914bcd6ac0b667ef2d89600abd1d7e47be7b6c7 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Fri, 21 Jan 2011 05:59:12 -0800 Subject: [PATCH] Brought in file from ~ backup files, as it was on 2011-01-21 --- remove-dup-mails-from-maildir.plx | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/remove-dup-mails-from-maildir.plx b/remove-dup-mails-from-maildir.plx index 33080e9..89ef4e7 100755 --- a/remove-dup-mails-from-maildir.plx +++ b/remove-dup-mails-from-maildir.plx @@ -6,14 +6,16 @@ use warnings; use Mail::Header; use File::Copy; -if (@ARGV < 2) { - print STDERR "usage: $0 [ ...]\n"; +my $RM_CMD = "/bin/rm"; + +if (@ARGV < 1) { + print STDERR "usage: $0 [ ...]\n"; exit 1; } -my($TYPE, $MAILDIR_FOLDER) = ($ARGV[0], $ARGV[1]); +my($MAILDIR_FOLDER) = $ARGV[0]; -my (@dupFolders) = @ARGV[2..$#ARGV]; +my (@dupFolders) = @ARGV[1..$#ARGV]; my %msgs; # indexed by Message-Id @@ -80,17 +82,9 @@ foreach my $dir (@msgDirs) { # it to %msgs. if (defined $msgs{$id}) { - if ($TYPE eq "print") { - print "$id\n"; - } elsif ($TYPE eq "svn") { - system("svn rm \"$existing_file\""); - die "Unable to unlink file $existing_file: $!" - unless $? == 0; - } else { - print STDERR "Removing $existing_file\n"; - die "Unable to unlink $existing_file: $!" - unless unlink($existing_file) == 1; - } + system("$RM_CMD \"$existing_file\""); + die "Unable to unlink file $existing_file: $!" + unless $? == 0; } else { $msgs{$id} = $fields; }