#! /bin/sh # $Id: append,v 1.12 92/07/24 17:35:58 jerry book2 $ ### 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 ## YOU CAN MODIFY THE case "$1" BELOW TO LET YOU TYPE ABBREVIATIONS ## FOR FILENAMES YOU USE A LOT. ## ## 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. ## Edward Vielmetti added the "filename abbreviation" setup. ## ## NOTE TO HACKERS: TABSTOPS ARE SET AT 4 IN THIS CODE 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 ;; *) # WIRE IN COMMON NAMES HERE. COMMENT OUT IF NOT USING. -emv case "$1" in # sig) files="$files $HOME/.signature" ;; # sep) files="$files $HOME/Mail/separator" ;; *) files="$files $1" ;; esac shift ;; esac done ;; esac eval cat $files '>>' $msg # EXPAND ENVARIABLES IN $files (PROTECT >>) exit 0 # FAKE SUCCESS TO KEEP MH FROM DELETING DRAFT IF cat FAILED
[Table of Contents] [Index] [Return to Explanation of append]
This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright © 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely-available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.
Suggestions are welcome: Jerry Peek <jpeek@jpeek.com>