summaryrefslogtreecommitdiff
path: root/usr.bin/mail
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2008-07-16 15:11:17 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2008-07-16 15:11:17 +0000
commit2c38c491b97bc716d7cebd790454dd87d79d68ac (patch)
tree0adfdde4e6ebf5e4043cc4dc1e53e964a8a0a7af /usr.bin/mail
parent34ea02bb9c6b61dab9766c85843a6b34824c8115 (diff)
add -E flag and 'skipempty' option to skip sending messages with
empty bodies. useful for sending mails from crontabs. from rivo nurges <rix at estpak dot ee>, with missing 'skipempty' documentation and usage update from me ok millert@
Diffstat (limited to 'usr.bin/mail')
-rw-r--r--usr.bin/mail/mail.112
-rw-r--r--usr.bin/mail/main.c18
-rw-r--r--usr.bin/mail/send.c6
3 files changed, 24 insertions, 12 deletions
diff --git a/usr.bin/mail/mail.1 b/usr.bin/mail/mail.1
index f2f4fba45dd..1457121cb37 100644
--- a/usr.bin/mail/mail.1
+++ b/usr.bin/mail/mail.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mail.1,v 1.52 2008/07/16 14:56:11 martynas Exp $
+.\" $OpenBSD: mail.1,v 1.53 2008/07/16 15:11:16 martynas Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -40,7 +40,7 @@
.Sh SYNOPSIS
.Nm mail
.Bk -words
-.Op Fl Iinv
+.Op Fl EIinv
.Op Fl b Ar list
.Op Fl c Ar list
.Op Fl s Ar subject
@@ -48,11 +48,11 @@
.Op Fl Ar sendmail-options ...
.Ek
.Nm mail
-.Op Fl IiNnv
+.Op Fl EIiNnv
.Fl f
.Op Ar file
.Nm mail
-.Op Fl IiNnv
+.Op Fl EIiNnv
.Op Fl u Ar user
.Sh DESCRIPTION
.Nm mail
@@ -72,6 +72,8 @@ Send carbon copies to
of users.
.Ar list
should be a comma separated list of names.
+.It Fl E
+Don't send messages with an empty body.
.It Fl f Op Ar file
Read in the contents of your mailbox
(or the specified
@@ -954,6 +956,8 @@ can be used to limit the search for
to just the
.Dq To:
field.
+.It Ar skipempty
+Don't send messages with an empty body.
.It Ar verbose
Setting the option
.Ar verbose
diff --git a/usr.bin/mail/main.c b/usr.bin/mail/main.c
index 841d439cac6..75d9ed99e9a 100644
--- a/usr.bin/mail/main.c
+++ b/usr.bin/mail/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.20 2007/08/06 19:16:06 sobrado Exp $ */
+/* $OpenBSD: main.c,v 1.21 2008/07/16 15:11:16 martynas Exp $ */
/* $NetBSD: main.c,v 1.7 1997/05/13 06:15:57 mikel Exp $ */
/*
@@ -40,7 +40,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/20/95";
#else
-static const char rcsid[] = "$OpenBSD: main.c,v 1.20 2007/08/06 19:16:06 sobrado Exp $";
+static const char rcsid[] = "$OpenBSD: main.c,v 1.21 2008/07/16 15:11:16 martynas Exp $";
#endif
#endif /* not lint */
@@ -92,7 +92,7 @@ main(int argc, char **argv)
bcc = NULL;
smopts = NULL;
subject = NULL;
- while ((i = getopt(argc, argv, "INT:b:c:dfins:u:v")) != -1) {
+ while ((i = getopt(argc, argv, "EINT:b:c:dfins:u:v")) != -1) {
switch (i) {
case 'T':
/*
@@ -182,6 +182,12 @@ main(int argc, char **argv)
*/
bcc = cat(bcc, nalloc(optarg, GBCC));
break;
+ case 'E':
+ /*
+ * Don't send messages with an empty body.
+ */
+ assign("skipempty", "");
+ break;
default:
usage();
/*NOTREACHED*/
@@ -290,11 +296,11 @@ __dead void
usage(void)
{
- fprintf(stderr, "usage: %s [-Iinv] [-b list] [-c list] "
+ fprintf(stderr, "usage: %s [-EIinv] [-b list] [-c list] "
"[-s subject] to-addr ...\n", __progname);
fprintf(stderr, " %*s [-sendmail-options ...]\n",
(int)strlen(__progname), "");
- fprintf(stderr, " %s [-IiNnv] -f [name]\n", __progname);
- fprintf(stderr, " %s [-IiNnv] [-u user]\n", __progname);
+ fprintf(stderr, " %s [-EIiNnv] -f [name]\n", __progname);
+ fprintf(stderr, " %s [-EIiNnv] [-u user]\n", __progname);
exit(1);
}
diff --git a/usr.bin/mail/send.c b/usr.bin/mail/send.c
index eeed4e4bff0..cfe041d8344 100644
--- a/usr.bin/mail/send.c
+++ b/usr.bin/mail/send.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: send.c,v 1.19 2008/07/16 14:53:41 martynas Exp $ */
+/* $OpenBSD: send.c,v 1.20 2008/07/16 15:11:16 martynas Exp $ */
/* $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static const char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93";
#else
-static const char rcsid[] = "$OpenBSD: send.c,v 1.19 2008/07/16 14:53:41 martynas Exp $";
+static const char rcsid[] = "$OpenBSD: send.c,v 1.20 2008/07/16 15:11:16 martynas Exp $";
#endif
#endif /* not lint */
@@ -339,6 +339,8 @@ mail1(struct header *hp, int printheaders)
if ((mtf = collect(hp, printheaders)) == NULL)
return;
if (fsize(mtf) == 0) {
+ if (value("skipempty") != NULL)
+ goto out;
if (hp->h_subject == NULL)
puts("No message, no subject; hope that's ok");
else