about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2018-09-25 13:59:58 +0200
committerLeah Neukirchen <leah@vuxu.org>2018-09-25 13:59:58 +0200
commitddd7e54fbbf6747ccefabbbad0087debcaec2ca5 (patch)
tree6222722717d63fa07feffac1a53cbfef2a3198e7
parent82faec5cfed1da6b4bd1d770fdcd214cca7f1050 (diff)
downloadmblaze-ddd7e54fbbf6747ccefabbbad0087debcaec2ca5.tar.gz
mblaze-ddd7e54fbbf6747ccefabbbad0087debcaec2ca5.tar.xz
mblaze-ddd7e54fbbf6747ccefabbbad0087debcaec2ca5.zip
mscan: hide message count behind -v
Also ensure output is flushed before printing it.
-rw-r--r--man/mscan.113
-rw-r--r--mscan.c10
2 files changed, 15 insertions, 8 deletions
diff --git a/man/mscan.1 b/man/mscan.1
index 48d4794..fb289a6 100644
--- a/man/mscan.1
+++ b/man/mscan.1
@@ -1,4 +1,4 @@
-.Dd June 28, 2017
+.Dd September 25, 2018
 .Dt MSCAN 1
 .Os
 .Sh NAME
@@ -6,9 +6,10 @@
 .Nd generate one-line message summaries
 .Sh SYNOPSIS
 .Nm
+.Op Fl I
 .Op Fl n
+.Op Fl v
 .Op Fl f Ar format
-.Op Fl I
 .Ar msgs\ ...
 .Sh DESCRIPTION
 .Nm
@@ -55,13 +56,15 @@ format may be specified in the user's
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
-.It Fl n
-Only print message numbers
-.Pq or filenames, if the message is not in the current sequence .
 .It Fl I
 Force ISO date output,
 even for
 .Sq Cm "%d" .
+.It Fl n
+Only print message numbers
+.Pq or filenames, if the message is not in the current sequence .
+.It Fl v
+Print how many messages were scanned to standard error.
 .It Fl f Ar format
 Format according to the string
 .Ar format ,
diff --git a/mscan.c b/mscan.c
index 5742ce8..3be986e 100644
--- a/mscan.c
+++ b/mscan.c
@@ -29,6 +29,7 @@ static int alias_idx;
 
 static int Iflag;
 static int nflag;
+static int vflag;
 static int curyear;
 static time_t now;
 static char default_fflag[] = "%c%u%r %-3n %10d %17f %t %2i%s";
@@ -493,13 +494,14 @@ main(int argc, char *argv[])
 	pid_t pid1 = -1;
 
 	int c;
-	while ((c = getopt(argc, argv, "If:n")) != -1)
+	while ((c = getopt(argc, argv, "If:nv")) != -1)
 		switch (c) {
 		case 'I': Iflag++; break;
 		case 'f': fflag = optarg; break;
 		case 'n': nflag = 1; break;
+		case 'v': vflag = 1; break;
 		default:
-			fprintf(stderr, "Usage: mscan [-n] [-f format] [-I] [msgs...]\n");
+			fprintf(stderr, "Usage: mscan [-Inv] [-f format] [msgs...]\n");
 			exit(1);
 		}
 
@@ -568,10 +570,12 @@ main(int argc, char *argv[])
 		i = blaze822_loop1(":", oneline);
 	else
 		i = blaze822_loop(argc-optind, argv+optind, oneline);
-	fprintf(stderr, "%ld mails scanned\n", i);
 
 	if (pid1 > 0)
 		pipeclose(pid1);
 
+	if (vflag)
+		fprintf(stderr, "%ld mails scanned\n", i);
+
 	return 0;
 }