about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMeudwy <meudwy@meudwy.uk>2023-07-25 11:55:26 +0100
committerLeah Neukirchen <leah@vuxu.org>2023-07-25 16:07:38 +0200
commit75de7d47da797b5cf6e7a859a1bff030f7b571a3 (patch)
tree477c73988a9ded37345799e28ed2c4f7d789d666
parent43f2cb8b491d95eb79b6b6d404865135971fe642 (diff)
downloadmblaze-75de7d47da797b5cf6e7a859a1bff030f7b571a3.tar.gz
mblaze-75de7d47da797b5cf6e7a859a1bff030f7b571a3.tar.xz
mblaze-75de7d47da797b5cf6e7a859a1bff030f7b571a3.zip
minc: read directory names from stdin
This matches `mlist` where it can take directories as arguments or via
stdin.

Closes: #244 [via git-merge-pr]
-rw-r--r--GNUmakefile4
-rw-r--r--man/minc.13
-rw-r--r--minc.c13
-rw-r--r--t/9000-minc.t8
4 files changed, 20 insertions, 8 deletions
diff --git a/GNUmakefile b/GNUmakefile
index c90e938..89cb779 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -28,8 +28,8 @@ all: $(ALL) museragent
 $(ALL) : % : %.o
 maddr magrep mdeliver mexport mflag mflow mgenmid mhdr mpick mscan msed mshow \
   msort mthread : blaze822.o mymemmem.o mytimegm.o
-maddr magrep mdeliver mexport mflag mgenmid mhdr mlist mpick mscan msed mseq \
-  mshow msort mthread : seq.o slurp.o mystrverscmp.o
+maddr magrep mdeliver mexport mflag mgenmid mhdr minc mlist mpick mscan msed \
+  mseq mshow msort mthread : seq.o slurp.o mystrverscmp.o
 maddr magrep mflow mhdr mpick mscan mshow : rfc2047.o
 magrep mflow mhdr mshow : rfc2045.o
 mshow : filter.o safe_u8putstr.o rfc2231.o pipeto.o
diff --git a/man/minc.1 b/man/minc.1
index cb71c85..6b7f96c 100644
--- a/man/minc.1
+++ b/man/minc.1
@@ -17,6 +17,9 @@ by moving them from
 to
 .Pa cur ,
 and adjusting the filenames.
+If used non-interactively with no specified folders,
+.Nm
+reads directory names from the standard input.
 .Pp
 By default, the new filenames are printed,
 separated by newlines.
diff --git a/minc.c b/minc.c
index c1d28fd..2811646 100644
--- a/minc.c
+++ b/minc.c
@@ -74,14 +74,17 @@ usage:
 			exit(1);
 		}
 
-	if (optind == argc)
-		goto usage;
-
 	xpledge("stdio rpath cpath", "");
 
 	status = 0;
-	for (i = optind; i < argc; i++)
-		inc(argv[i]);
+	if (optind == argc) {
+		if (isatty(0))
+			goto usage;
+		blaze822_loop(0, 0, inc);
+	} else {
+		for (i = optind; i < argc; i++)
+			inc(argv[i]);
+	}
 
 	return status;
 }
diff --git a/t/9000-minc.t b/t/9000-minc.t
index 3d5b789..9b29194 100644
--- a/t/9000-minc.t
+++ b/t/9000-minc.t
@@ -1,7 +1,7 @@
 #!/bin/sh -e
 cd ${0%/*}
 . ./lib.sh
-plan 1
+plan 2
 
 rm -rf test.dir
 mkdir test.dir
@@ -16,4 +16,10 @@ inbox/new/2
 
 check_test 'minc' -eq 2 'minc inbox | wc -l'
 
+while read f; do touch "$f"; done <<!
+inbox/new/3:2,
+inbox/new/4
+!
+
+check_test 'minc stdin' -eq 2 'echo inbox | minc | wc -l'
 )