mdirs: add -a to list all subfolders, ignoring maildir++ convention

Based on a patch by Kylie McClain <kylie@somas.is>.
pull/170/head
Leah Neukirchen 4 years ago
parent 1755fa6279
commit 113ac5a24d

@ -1,4 +1,4 @@
.Dd July 22, 2016 .Dd January 22, 2020
.Dt MDIRS 1 .Dt MDIRS 1
.Os .Os
.Sh NAME .Sh NAME
@ -6,7 +6,7 @@
.Nd list maildir folders, recursively .Nd list maildir folders, recursively
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl 0 .Op Fl 0a
.Ar dirs\ ... .Ar dirs\ ...
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
@ -27,11 +27,14 @@ and
By the maildir++ convention, nested maildir folder By the maildir++ convention, nested maildir folder
names must begin with names must begin with
.Sq Li \&. . .Sq Li \&. .
.Pq This can be disabled using Fl a .
.Pp .Pp
The options are as follows: The options are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl 0 .It Fl 0
Print folders separated by a NUL character. Print folders separated by a NUL character.
.It Fl a
Traverse into all subfolders, without considering the maildir++ name conventions.
.El .El
.Sh EXIT STATUS .Sh EXIT STATUS
.Ex -std .Ex -std

@ -10,6 +10,7 @@
#include "blaze822.h" #include "blaze822.h"
static char sep = '\n'; static char sep = '\n';
int aflag;
void void
pwd() pwd()
@ -58,7 +59,7 @@ mdirs(char *fpath)
d->d_name[2] == 0) d->d_name[2] == 0)
continue; continue;
if (dotonly && d->d_name[0] != '.') if (!aflag && dotonly && d->d_name[0] != '.')
continue; continue;
mdirs(d->d_name); mdirs(d->d_name);
@ -74,12 +75,13 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int c, i; int c, i;
while ((c = getopt(argc, argv, "0")) != -1) while ((c = getopt(argc, argv, "0a")) != -1)
switch (c) { switch (c) {
case '0': sep = '\0'; break; case '0': sep = '\0'; break;
case 'a': aflag = 1; break;
default: default:
usage: usage:
fprintf(stderr, "Usage: mdirs [-0] dirs...\n"); fprintf(stderr, "Usage: mdirs [-0a] dirs...\n");
exit(1); exit(1);
} }

Loading…
Cancel
Save