Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jan 1999 21:33:06 +0100 (CET)
From:      Christoph Weber-Fahr <wefa@paris.callcenter.systemhaus.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/9494: small extension to /usr/bin/mail
Message-ID:  <199901142033.VAA04670@paris.otelo-call.de>

next in thread | raw e-mail | index | archive | help

>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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901142033.VAA04670>