From: epg@pretzelnet.org <> Date: Wed, 1 Apr 2009 21:28:17 +0000 (-0700) Subject: Don't try \r line-erasing tricks if stdout is not a tty. X-Git-Url: https://diplodocus.org/git/minc/commitdiff_plain/fbeff8e387d16985ccfbacd67f013703a32301f0 Don't try \r line-erasing tricks if stdout is not a tty. --- diff --git a/minc b/minc index 1ec929a..eec56e4 100755 --- a/minc +++ b/minc @@ -636,6 +636,12 @@ sub filter_mail { } } + my $tty = -t STDOUT; + if (not $tty) { + # Print a newline after the incomplete "N messages..." line. + print("\n"); + } + for $msg (@_) { ($msg eq '.' or $msg eq '..') and next; @@ -653,9 +659,12 @@ sub filter_mail { $msgnum = store_message($msg, $mhfolder); $folders{$mhfolder}++; + if ($tty) { + print("\r"); + } + if ($mhfolder eq 'SPAM') { $spam++; - print("\r"); } else { $saved++; my $from = ''; @@ -666,7 +675,7 @@ sub filter_mail { for ($from, $subject) { tr/\x00-\x1f\x80-\xff/ /; } - printf("\r\%-${nf}s \%${nm}d \%-${nF}s \%s\n", + printf("\%-${nf}s \%${nm}d \%-${nF}s \%s\n", substr($mhfolder, 0, $nf), substr($msgnum, 0, $nm), substr($from, 0, $nF), substr($subject, 0, $ns)); @@ -676,8 +685,10 @@ sub filter_mail { $hook->(\%batons, \%headers, $mhfolder, $msgnum); } - printf(" \%${len}d SPAM \%${len}d saved \%${len}d/%1d", - $spam, $saved, $spam + $saved, $msgcount); + if ($tty) { + printf(" \%${len}d SPAM \%${len}d saved \%${len}d/%1d", + $spam, $saved, $spam + $saved, $msgcount); + } defined($maxmsgs) and ($spam + $saved < $maxmsgs or last); }