From owner-freebsd-bugs Thu Jan 14 12:42:02 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id MAA04612 for freebsd-bugs-outgoing; Thu, 14 Jan 1999 12:40:38 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA04603 for ; Thu, 14 Jan 1999 12:40:36 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id MAA13933; Thu, 14 Jan 1999 12:40:00 -0800 (PST) Received: from custos.callcenter.systemhaus.net ([62.152.9.34]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA04413 for ; Thu, 14 Jan 1999 12:39:07 -0800 (PST) (envelope-from wefa@paris.callcenter.systemhaus.net) Received: (from smap@localhost) by custos.callcenter.systemhaus.net (8.8.5/8.8.5) id VAA06627 for ; Thu, 14 Jan 1999 21:25:51 +0100 (CET) Received: from paris.otelo-call.de(194.233.120.27) by custos.otelo-call.de via smap (V2.1) id xma006625; Thu, 14 Jan 99 21:25:45 +0100 Received: (from root@localhost) by paris.otelo-call.de (8.8.8/8.8.8) id VAA04670; Thu, 14 Jan 1999 21:33:06 +0100 (CET) Message-Id: <199901142033.VAA04670@paris.otelo-call.de> Date: Thu, 14 Jan 1999 21:33:06 +0100 (CET) From: Christoph Weber-Fahr Reply-To: wefa@paris.callcenter.systemhaus.net To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.2 Subject: bin/9494: small extension to /usr/bin/mail Sender: owner-freebsd-bugs@FreeBSD.org Precedence: bulk X-Loop: FreeBSD.org >Number: 9494 >Category: bin >Synopsis: new option to prevent mail from sending mail without input >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Jan 14 12:40:00 PST 1999 >Closed-Date: >Last-Modified: >Originator: Christoph Weber-Fahr >Release: FreeBSD 2.2.7-RELEASE i386 >Organization: O.tel.o Communications >Environment: The diff comes from the 2.2-STABLE Sources as of 15 Jan 1999 >Description: Sometimes I use /usr/bin/mail to get the output of scripts. Usually I'm only interested in these if there is any output (e.g. Error Messages). The newly introduced commandline switch -e prevents /usr/bin/mail from sending me empty messages. There is already such functionality in cron; however this gives better control and solves the problem on a more general scale. >How-To-Repeat: Old: wefa@paris 21:29 [~] echo | mail -s Test1 wefa Null message body; hope that's ok Apply patch. New: wefa@paris 21:29 [~] echo | mail -es Test1 wefa wefa@paris 21:29 [~] >Fix: Output from diff -c mail mail.cwf: ------------------------------------------ Common subdirectories: mail/USD.doc and mail.cwf/USD.doc diff -c mail/glob.h mail.cwf/glob.h *** mail/glob.h Thu Jan 14 14:56:20 1999 --- mail.cwf/glob.h Thu Jan 14 16:12:25 1999 *************** *** 38,43 **** --- 38,45 ---- * def.h must be included first. */ + int noEmptyMail; /* do not send empty Mail from + stdin */ int msgCount; /* Count of messages read in */ int rcvmode; /* True if receiving mail */ int sawcom; /* Set after first command */ diff -c mail/mail.1 mail.cwf/mail.1 *** mail/mail.1 Thu Jan 14 14:56:21 1999 --- mail.cwf/mail.1 Thu Jan 14 21:12:59 1999 *************** *** 91,96 **** --- 91,99 ---- .Fl s flag is used as a subject; be careful to quote subjects containing spaces.) + .It Fl e + discard empty mail messages, if mailing data from stdin + (usefull for use within scripts) .It Fl c Send carbon copies to .Ar list diff -c mail/main.c mail.cwf/main.c *** mail/main.c Thu Jan 14 14:56:20 1999 --- mail.cwf/main.c Thu Jan 14 15:31:08 1999 *************** *** 91,97 **** smopts = NIL; subject = NOSTR; replyto = NOSTR; ! while ((i = getopt(argc, argv, "INT:b:c:dfins:u:v")) != -1) { switch (i) { case 'T': /* --- 91,98 ---- smopts = NIL; subject = NOSTR; replyto = NOSTR; ! noEmptyMail = 0; ! while ((i = getopt(argc, argv, "INT:b:c:defins:u:v")) != -1) { switch (i) { case 'T': /* *************** *** 120,125 **** --- 121,129 ---- break; case 'd': debug++; + break; + case 'e': + noEmptyMail++; break; case 's': /* Common subdirectories: mail/misc and mail.cwf/misc diff -c mail/send.c mail.cwf/send.c *** mail/send.c Thu Jan 14 14:56:20 1999 --- mail.cwf/send.c Thu Jan 14 21:09:39 1999 *************** *** 320,326 **** (void) fflush(stdout); } if (fsize(mtf) == 0) ! if (hp->h_subject == NOSTR) printf("No message, no subject; hope that's ok\n"); else printf("Null message body; hope that's ok\n"); --- 320,328 ---- (void) fflush(stdout); } if (fsize(mtf) == 0) ! if (noEmptyMail) ! return; ! else if (hp->h_subject == NOSTR) printf("No message, no subject; hope that's ok\n"); else printf("Null message body; hope that's ok\n"); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message