about summary refs log tree commit diff
path: root/mhdr.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-08-08 14:23:20 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-08-08 14:23:20 +0200
commit914b78a58f5dc668bbe6106e366a3bb18813cfbb (patch)
tree5c597dc7f12f26f541666503353971d74bc549d5 /mhdr.c
parent21d353f91e9cb3869334a9118173d86b3fa8c6da (diff)
downloadmblaze-914b78a58f5dc668bbe6106e366a3bb18813cfbb.tar.gz
mblaze-914b78a58f5dc668bbe6106e366a3bb18813cfbb.tar.xz
mblaze-914b78a58f5dc668bbe6106e366a3bb18813cfbb.zip
mhdr: set exit status to 1 when no header was found
Diffstat (limited to 'mhdr.c')
-rw-r--r--mhdr.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/mhdr.c b/mhdr.c
index 97b99e1..955c0f2 100644
--- a/mhdr.c
+++ b/mhdr.c
@@ -17,6 +17,8 @@ static int Dflag;
 static int Mflag;
 static int dflag;
 
+static int status;
+
 static void
 printhdr(char *hdr)
 {
@@ -29,6 +31,8 @@ printhdr(char *hdr)
 	}
 	fputs(hdr, stdout);
 	fputc('\n', stdout);
+
+	status = 0;
 }
 
 void
@@ -88,6 +92,8 @@ print_decode_header(char *s)
 void
 print_header(char *v)
 {
+	status = 0;
+
 	if (Aflag)
 		print_addresses(v);
 	else if (Dflag)
@@ -179,13 +185,15 @@ main(int argc, char *argv[])
 		default:
 			fprintf(stderr,
 "Usage: mhdr [-h header] [-d] [-M] [-A|-D] [msgs...]\n");
-			exit(1);
+			exit(2);
 		}
 
+	status = 1;
+
 	if (argc == optind && isatty(0))
 		blaze822_loop1(".", header);
 	else
 		blaze822_loop(argc-optind, argv+optind, header);
 	
-	return 0;
+	return status;
 }