[comp.mail.mh] extension to "append" from octopus book

emv@ox.com (Ed Vielmetti) (03/20/91)

here's a little hack you might like.

i often use MH to include my signature.  this through the magic of the
"append" shell script which you get from the octopus book, e.g.
	What now? ed append $HOME/.signature

now aside from the fact that that is a lot of stuff to type, it's kind
of silly to type it in all the time.  so a quick hack to append lets
you specify common files in shorthand.
	What now? ed append sig

-- 
 Msen	Edward Vielmetti
/|---	moderator, comp.archives
	emv@msen.com

#! /bin/sh
###	append - append file(s) to an MH mail message
###	Usage:   What now? e append file [files...]
##
##	THIS SCRIPT LETS YOU APPEND ONE OR MORE FILES TO A DRAFT MH MAIL
##	MESSAGE; IT ALSO ALLOWS WILDCARDS AND ENVARIABLES.
##	YOU CALL IT AS AN EDITOR, AT THE What now? PROMPT.
##	FOR EXAMPLE, TO APPEND A COPY OF YOUR FILE report TO YOUR DRAFT:
##		What now? e append report
##
##	AFTER IT APPENDS THE FILE(S), YOU GET ANOTHER What now? PROMPT.
##	IF YOU WANT TO SEPARATE THE FILES WITH BLANK LINES, ROWS OF DASHES,
##	OR WHATEVER, AN EASY WAY IS TO MAKE A LITTLE FILE NAMED SOMETHING
##	LIKE SEP WITH THAT SEPARATOR IN IT.  THIS NEXT EXAMPLE SHOWS HOW TO
##	APPEND ALL THE FILES FROM THE $HOME/proj DIRECTORY WHOSE NAMES END
##	WITH .out, THEN YOUR SEPARATOR FILE, THEN THE FILE .signature:
##		What now? e append $HOME/proj/*.out sep .signature
#
# Original, apparently by John Romine, from the paper
# "MH.5: How to process 200 messages a day and still get some
# real work done," in the Summer 1985 USENIX Proceedings.
# Hacked more by Jerry Peek, with hints from John Romine.
# special case names by Edward Vielmetti, emv@msen.com

case $# in
0)	echo 1>&2 "`basename $0`: shouldn't get here!"; exit 1;;
1)	echo 1>&2 "Usage: e[dit] `basename $0` file [files...]"; exit 1 ;;
*)	while :
	do
		case $# in
		1)	msg=$1; break ;;
		*)	case $1 in
		# wire in commonly used names here.  emv
			sig)	files="$files /u1/emv/.sig.msen"; shift;;
			sep)    files="$files /u1/emv/Mail/separator"; shift;;
			*)	files="$files $1"; shift ;;
			esac ;;
		esac
	done
	;;
esac

# eval EXPANDS ENVIRONMENT VARIABLES IN $files; BUT PROTECT >> FROM eval:
eval cat $files '>>' $msg