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

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

Loading…
Cancel
Save