about summary refs log tree commit diff
path: root/mdirs.c
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 /mdirs.c
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.
Diffstat (limited to 'mdirs.c')
-rw-r--r--mdirs.c9
1 files changed, 6 insertions, 3 deletions
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);
 		}