about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2019-02-20 10:56:56 +0100
committerLeah Neukirchen <leah@vuxu.org>2019-02-20 10:57:50 +0100
commitf8fa6a1e0e0dbd115544cd8e8716e7221ac1f3cb (patch)
tree4c547ddd5175836af65c39cb36acc1fcab205e72
parent085138d6a25a8269c3fcf27472f26f4508f8cb2e (diff)
downloadmblaze-f8fa6a1e0e0dbd115544cd8e8716e7221ac1f3cb.tar.gz
mblaze-f8fa6a1e0e0dbd115544cd8e8716e7221ac1f3cb.tar.xz
mblaze-f8fa6a1e0e0dbd115544cd8e8716e7221ac1f3cb.zip
mdirs: add -0 to separate folders by NUL characters
Idea by Mario Domgoergen <mdom@taz.de>.

Closes #159.
-rw-r--r--man/mdirs.17
-rw-r--r--mdirs.c9
2 files changed, 12 insertions, 4 deletions
diff --git a/man/mdirs.1 b/man/mdirs.1
index b0cf9e6..4eb0237 100644
--- a/man/mdirs.1
+++ b/man/mdirs.1
@@ -6,6 +6,7 @@
 .Nd list maildir folders, recursively
 .Sh SYNOPSIS
 .Nm
+.Op Fl 0
 .Ar dirs\ ...
 .Sh DESCRIPTION
 .Nm
@@ -27,7 +28,11 @@ By the maildir++ convention, nested maildir folder
 names must begin with
 .Sq Li \&. .
 .Pp
-There are currently no options.
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl 0
+Print folders separated by a NUL character.
+.El
 .Sh EXIT STATUS
 .Ex -std
 .Sh SEE ALSO
diff --git a/mdirs.c b/mdirs.c
index 18ba9da..3c5fcbc 100644
--- a/mdirs.c
+++ b/mdirs.c
@@ -9,12 +9,14 @@
 
 #include "blaze822.h"
 
+static char sep = '\n';
+
 void
 pwd()
 {
 	char cwd[PATH_MAX];
 	if (getcwd(cwd, sizeof cwd))
-		puts(cwd);
+		printf("%s%c", cwd, sep);
 }
 
 void
@@ -72,11 +74,12 @@ int
 main(int argc, char *argv[])
 {
 	int c, i;
-	while ((c = getopt(argc, argv, "")) != -1)
+	while ((c = getopt(argc, argv, "0")) != -1)
 		switch (c) {
+		case '0': sep = '\0'; break;
 		default:
 usage:
-			fprintf(stderr, "Usage: mdirs dirs...\n");
+			fprintf(stderr, "Usage: mdirs [-0] dirs...\n");
 			exit(1);
 		}