#! /bin/sh
# $Id: resend.fixmsg,v 1.6 92/07/24 18:23:58 jerry book2 $
### resend.fixmsg - editor for fixing up returned mail
### Usage in MH profile:  resend: -editor resend.fixmsg -nodashmunging
###   MUST ALSO ADD:   -format   OR   -filter xxx
##
##  TO USE THIS, FIRST MAKE A VERSION OF forw NAMED resend
##  (MAKE SYMBOLIC LINK TO forw, ETC.).  THEN, ADD THE ENTRY
##  SHOWN ABOVE TO YOUR MH profile file.
##
##  WHEN YOU START resend, IT BUILDS A DRAFT AND CALLS
##  resend.fixmsg TO EDIT IT.  resend.fixmsg MAKES THE MESSAGE
##  LOOK ALMOST EXACTLY AS IT DID THE FIRST TIME YOU COMPOSED
##  IT, THEN STARTS AN EDITOR (DEFAULT: vi) TO FIX THE ADDRESS.
# 
#                             NO WARRANTY
# 
#   BECAUSE THIS PROGRAM IS AVAILABLE FREE OF CHARGE, THERE IS NO WARRANTY
# FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
# OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
# PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
# OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
# TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
# PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
# REPAIR OR CORRECTION.
# 
#   IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
# WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
# REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
# INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
# OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
# TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
# YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
# PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.


# $1 IS PATH TO DRAFT (SET BY forw).  THEN ed SCRIPT:
# DELETES LINES THROUGH FIRST "To: (you)".
# DELETES LINES TO BUT NOT INCLUDING NEXT "To: (original)".
# REMOVES Date:/From:/Sender: LINES THAT MAILER PUT IN MESSAGE.
# REMOVES FROM BLANK LINE BEFORE "---- End of Forwarded Message"
#   THROUGH THE END OF THE FILE.
/bin/ed - $1 << "END"
1,/^To: /d
1,/^To: /-1d
1,/^$/g/^Date: /d
1,/^$/g/^From: /d
1,/^$/g/^Sender: /d
$
?^------- End of Forwarded Message?-1,$d
w
q
END

# EDIT WITH $VISUAL, $EDITOR OR vi.  exec TO SAVE A PROCESS:
exec ${VISUAL-${EDITOR-vi}} $1
