diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-08-09 15:49:46 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-08-09 15:49:46 +0200 |
commit | edf4458016077547b7e76b79971f86f19fbd1819 (patch) | |
tree | c623b1154ecacd5ae33f43f6b109352c1d18b8b9 | |
parent | cfec8ca377ba57b0e0638b9b7ae980c5ff2e6c41 (diff) | |
download | mblaze-edf4458016077547b7e76b79971f86f19fbd1819.tar.gz mblaze-edf4458016077547b7e76b79971f86f19fbd1819.tar.xz mblaze-edf4458016077547b7e76b79971f86f19fbd1819.zip |
maddr: -a to only print address part
-rw-r--r-- | maddr.c | 13 | ||||
-rw-r--r-- | man/maddr.1 | 3 |
2 files changed, 13 insertions, 3 deletions
diff --git a/maddr.c b/maddr.c index 13eb15e..cf6298f 100644 --- a/maddr.c +++ b/maddr.c @@ -8,6 +8,7 @@ #include "blaze822.h" +static int aflag; static char defaulthflags[] = "from:sender:reply-to:to:cc:bcc:" "resent-from:resent-sender:resent-to:resent-cc:resent-bcc:"; static char *hflag = defaulthflags; @@ -40,7 +41,11 @@ addr(char *file) sizeof dispdec - 1, "UTF-8"); dispdec[sizeof dispdec - 1] = 0; - printf("%s <%s>\n", dispdec, addr); + if (aflag) + printf("%s\n", addr); + else + printf("%s <%s>\n", + dispdec, addr); } else if (addr) { printf("%s\n", addr); } @@ -59,11 +64,13 @@ int main(int argc, char *argv[]) { int c; - while ((c = getopt(argc, argv, "h:")) != -1) + while ((c = getopt(argc, argv, "ah:")) != -1) switch(c) { + case 'a': aflag = 1; break; case 'h': hflag = optarg; break; default: - fprintf(stderr, "Usage: maddr [-h headers] [msgs...]\n"); + fprintf(stderr, + "Usage: maddr [-a] [-h headers] [msgs...]\n"); exit(1); } diff --git a/man/maddr.1 b/man/maddr.1 index 1f0df38..56d30f4 100644 --- a/man/maddr.1 +++ b/man/maddr.1 @@ -6,6 +6,7 @@ .Nd extract mail addresses from messages .Sh SYNOPSIS .Nm +.Op Fl a .Op Fl h Ar headers .Op Ar msgs\ ... .Sh DESCRIPTION @@ -33,6 +34,8 @@ will read filenames from standard input. .Pp The options are as follows: .Bl -tag -width Ds +.It Fl a +Only print the address part of the address, not the display name. .It Fl h Ar headers Only search the colon-separated list of .Ar headers |