#!/bin/sh
#
#  @(#)faces.sendmail 1.4 91/05/06
#
#  Small script to automatically add X-Face: compressed image lines to a
#  mail message header. This shell script should be run by adding a line
#  similar to:
#
#  set sendmail=/usr/local/bin/faces.sendmail
#
#  to your ~/.mailrc file. See the faces manual pages for more details, and
#  how to setup yout ~/.face file.
# 
#  Copyright 1990, 1991 John J. Mackin. All rights reserved.
#
#  Permission is given to distribute these sources, as long as the
#  copyright messages are not removed, and no monies are exchanged.
#
#  No responsibility is taken for any errors or inaccuracies inherent
#  either to the comments or the code of this program, but if
#  reported to me then an attempt will be made to fix them.
#
cat $HOME/.face - | sed -n \
	-e '1s/^/X-Face:/' \
	-e 1h \
	-e 1d \
	-e '/^[ 	]/{H;d;}' \
	-e ': copy0' \
	-e '/^$/!{p;n;}' \
	-e '/^$/!b copy0' \
	-e g \
	-e p \
	-e 'a\

' \
	-e n \
	-e ': copy' \
	-e p \
	-e n \
	-e 'b copy' | /usr/sbin/sendmail "$@"
