#! /bin/sh
# $Id: mydist,v 1.2 92/08/03 08:45:38 jerry book2 $
### mydist - workaround for dist/sendproc problem in "mysend"
### Usage: use as shell alias or function, or rename to "dist"
##
##  THERE SEEMS TO BE A BUG IN MH 6.7.2 (AT LEAST) THAT WON'T
##  PASS THE -dist SWITCH TO THE post COMMAND IF AN EXTERNAL
##  sendproc (LIKE mysend) IS USED.  THE RESULT IS ERRORS LIKE
##  THESE IF YOU USE THAT sendproc DURING THE dist COMMAND:
##      What now? send
##      post: illegal header line -- Resent-To:
##      ...
##  THIS IS A FRONT-END dist SHELL SCRIPT THAT MAKES A
##  TEMPORARY COPY OF YOUR MH PROFILE WITHOUT ITS sendproc: ENTRY.
##  THEN IT RUNS THE REAL dist AND USES THAT MH PROFILE.
##
##  INSTALL THIS AS A C SHELL ALIAS OR BOURNE SHELL FUNCTION.
##  OR, RENAME THIS TO dist AND PUT IT IN YOUR SEARCH PATH BEFORE
##  THE REAL dist COMMAND.  THE "NOTE" MESSAGE WILL REMIND YOU.
# 
#                             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.


echo "NOTE: using workaround $0" 1>&2
stat=1  # DEFAULT EXIT STATUS; RESET BY dist
tempprfl=/tmp/MYDIST$$
trap 'rm -f $tempprfl; exit $stat' 0 1 2 15
sed '/^[Ss]endproc:/d' ${MH-$HOME/.mh_profile} >$tempprfl || exit
MH=$tempprfl /usr/local/mh/dist $*
stat=$?     # SAVE STATUS FROM dist FOR exit IN trap
exit
