mhdr: set exit status to 1 when no header was found

pull/2/head
Christian Neukirchen 8 years ago
parent 21d353f91e
commit 914b78a58f

@ -41,7 +41,11 @@ Scan for RFC 5322 addresses in the headers and print them line by line.
Assume header contains RFC 5322 date and print as Unix timestamp. Assume header contains RFC 5322 date and print as Unix timestamp.
.El .El
.Sh EXIT STATUS .Sh EXIT STATUS
.Ex -std The
.Nm
utility exits 0 on success,
1 when no header was printed,
and >1 if an error occurs.
.Sh SEE ALSO .Sh SEE ALSO
.Xr mmsg 7 .Xr mmsg 7
.Rs .Rs

@ -17,6 +17,8 @@ static int Dflag;
static int Mflag; static int Mflag;
static int dflag; static int dflag;
static int status;
static void static void
printhdr(char *hdr) printhdr(char *hdr)
{ {
@ -29,6 +31,8 @@ printhdr(char *hdr)
} }
fputs(hdr, stdout); fputs(hdr, stdout);
fputc('\n', stdout); fputc('\n', stdout);
status = 0;
} }
void void
@ -88,6 +92,8 @@ print_decode_header(char *s)
void void
print_header(char *v) print_header(char *v)
{ {
status = 0;
if (Aflag) if (Aflag)
print_addresses(v); print_addresses(v);
else if (Dflag) else if (Dflag)
@ -179,13 +185,15 @@ main(int argc, char *argv[])
default: default:
fprintf(stderr, fprintf(stderr,
"Usage: mhdr [-h header] [-d] [-M] [-A|-D] [msgs...]\n"); "Usage: mhdr [-h header] [-d] [-M] [-A|-D] [msgs...]\n");
exit(1); exit(2);
} }
status = 1;
if (argc == optind && isatty(0)) if (argc == optind && isatty(0))
blaze822_loop1(".", header); blaze822_loop1(".", header);
else else
blaze822_loop(argc-optind, argv+optind, header); blaze822_loop(argc-optind, argv+optind, header);
return 0; return status;
} }

Loading…
Cancel
Save