summary refs log tree commit diff
path: root/mshow.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2019-01-02 18:39:19 +0100
committerLeah Neukirchen <leah@vuxu.org>2019-01-02 18:39:19 +0100
commit1349f617de10d156b11480a30a69ea280500a75c (patch)
tree8824b79e4a21ca2c322aefbdf76a54a71542bf42 /mshow.c
parentae720c51e022fd07217ac77f7452821ca0033839 (diff)
downloadmblaze-1349f617de10d156b11480a30a69ea280500a75c.tar.gz
mblaze-1349f617de10d156b11480a30a69ea280500a75c.tar.xz
mblaze-1349f617de10d156b11480a30a69ea280500a75c.zip
mshow: exit with 1 if not all attachments were found
Diffstat (limited to 'mshow.c')
-rw-r--r--mshow.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/mshow.c b/mshow.c
index c4f5228..4b87f46 100644
--- a/mshow.c
+++ b/mshow.c
@@ -35,6 +35,7 @@ static char fallback_ct[] = "text/plain";
 struct message *filters;
 
 static int mimecount;
+static int extractcount;
 static int safe_output;
 
 static int reply_found;
@@ -525,6 +526,7 @@ extract_mime(int depth, struct message *msg, char *body, size_t bodylen)
 					printf("%s\n", bufptr);
 					writefile(bufptr, body, bodylen);
 				}
+				extractcount++;
 			} else if (filename &&
 			    fnmatch(a, filename, FNM_PATHNAME) == 0) {
 				// extract by name
@@ -545,6 +547,7 @@ extract_mime(int depth, struct message *msg, char *body, size_t bodylen)
 					printf("\n");
 					writefile(filename, body, bodylen);
 				}
+				extractcount++;
 			}
 		}
 	}
@@ -839,5 +842,10 @@ main(int argc, char *argv[])
 	if (pid1 > 0)
 		pipeclose(pid1);
 
+	if ((xflag || Oflag) && extractcount < argc-optind) {
+		fprintf(stderr, "mshow: could not extract all attachments\n");
+		return 1;
+	}
+
 	return 0;
 }