Thread (7 messages) flat view 7 messages, 4 authors, 2016-06-15

Re: [PATCH] Teach mailsplit about Maildir's

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:11

Possibly related (same subject, not in this thread)

Hi,

On Sun, 20 May 2007, Junio C Hamano wrote:
"Fernando J. Pereda" [off-list ref] writes:
quoted
-	ret = split_mbox(argp, dir, allow_bare, nr_prec, nr);
+	while (*argp) {
+		const char *arg = *argp++;
+		struct stat argstat;
+
+		if (arg[0] == '-' && arg[1] == 0) {
+			ret |= split_mbox(arg, dir, allow_bare, nr_prec, nr);
+			continue;
+		}
+
+		if (stat(arg, &argstat) == -1) {
+			error("cannot stat %s (%s)", arg, strerror(errno));
+			return 1;
+		}
+
+		if (S_ISDIR(argstat.st_mode))
+			ret |= split_maildir(arg, dir, nr_prec, nr);
+		else
+			ret |= split_mbox(arg, dir, allow_bare, nr_prec, nr);
+	}
+
 	if (ret != -1)
 		printf("%d\n", ret);
 
No kidding.  ret |= stuff and then printf("%d\n", ret) would not
give us the number of commit e-mails on the standard output.
Should we not just stop when split_maildir() or split_mbox() returns -1? 
And yes, we'd probably need a second variable to do take the return value.

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help