diff options
-rw-r--r-- | maddr.c | 23 | ||||
-rw-r--r-- | man/maddr.1 | 6 |
2 files changed, 20 insertions, 9 deletions
diff --git a/maddr.c b/maddr.c index 6f2e2e5..339acad 100644 --- a/maddr.c +++ b/maddr.c @@ -9,6 +9,7 @@ #include "blaze822.h" static int aflag; +static int dflag; static char defaulthflags[] = "from:sender:reply-to:to:cc:bcc:" "resent-from:resent-sender:resent-to:resent-cc:resent-bcc:"; static char *hflag = defaulthflags; @@ -63,15 +64,22 @@ addr(char *file) while ((v = blaze822_addr(v, &disp, &addr))) { if (disp && addr && strcmp(disp, addr) == 0) disp = 0; - if (disp && addr) { - if (aflag) { + + if (aflag) { + if (addr) printf("%s\n", addr); - } else { + } else if (dflag) { + if (disp) { + print_quoted(disp); + printf("\n"); + } + } else { + if (disp && addr) { print_quoted(disp); printf(" <%s>\n", addr); + } else if (addr) { + printf("%s\n", addr); } - } else if (addr) { - printf("%s\n", addr); } } } @@ -89,13 +97,14 @@ int main(int argc, char *argv[]) { int c; - while ((c = getopt(argc, argv, "ah:")) != -1) + while ((c = getopt(argc, argv, "adh:")) != -1) switch (c) { case 'a': aflag = 1; break; + case 'd': dflag = 1; break; case 'h': hflag = optarg; break; default: fprintf(stderr, - "Usage: maddr [-a] [-h headers] [msgs...]\n"); + "Usage: maddr [-ad] [-h headers] [msgs...]\n"); exit(1); } diff --git a/man/maddr.1 b/man/maddr.1 index 1e8b415..c38649f 100644 --- a/man/maddr.1 +++ b/man/maddr.1 @@ -1,4 +1,4 @@ -.Dd July 22, 2016 +.Dd March 30, 2020 .Dt MADDR 1 .Os .Sh NAME @@ -6,7 +6,7 @@ .Nd extract mail addresses from messages .Sh SYNOPSIS .Nm -.Op Fl a +.Op Fl ad .Op Fl h Ar headers .Op Ar msgs\ ... .Sh DESCRIPTION @@ -36,6 +36,8 @@ The options are as follows: .Bl -tag -width Ds .It Fl a Only print the addr-spec address, not the display name. +.It Fl d +Only print the display name. .It Fl h Ar headers Only search the colon-separated list of .Ar headers |