Only send a mail when there is at least one interesting date, added
authorJoey Schulze <joey@infodrom.org>
Fri, 2 May 2003 06:13:02 +0000 (06:13 +0000)
committerJoey Schulze <joey@infodrom.org>
Fri, 2 May 2003 06:13:02 +0000 (06:13 +0000)
CVS info

mail-calendar

index 91c6c3a..c0e96e3 100755 (executable)
 #   along with this program; if not, write to the Free Software
 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
 
+#   http://cvs.infodrom.org/calendar/mail-calendar?cvsroot=infodrom
+#   :pserver:anonymous@cvs.infodrom.org:/var/cvs/infodrom co calendar/mail-calendar
+#  
+#   $Id$
+
 opt_subject="Calendar for"
 opt_dateform="%B %d"
 opt_to=$LOGNAME
@@ -72,9 +77,17 @@ secs=$[ $opt_advance * 86400 ]
 c_date=`date -d now+${secs}seconds +%d.%m`
 s_date=`LANG=$opt_lang date -d now+${secs}seconds "+$opt_dateform"`
 
-(
-    echo "Subject: $opt_subject $s_date"
-    echo "To: $opt_to"
-    echo
-    calendar -l 0 -w 0 -t $c_date
-) | /usr/sbin/sendmail "$opt_to"
+tmp=`tempfile`
+trap 'rm -f $tmp' INT EXIT
+
+calendar -l 0 -w 0 -t $c_date > $tmp
+
+if [ -s $tmp ]
+then
+    (
+       echo "Subject: $opt_subject $s_date"
+       echo "To: $opt_to"
+       echo
+       calendar -l 0 -w 0 -t $c_date
+    ) | /usr/sbin/sendmail "$opt_to"
+fi