The Section Add Files to Your Drafts: append gives an overview of this script. Here is the append script (you might want to open it in a separate browser window). To install it, see the Section Programs in This Book's Archive.
The command line arguments are passed from the whatnow program. The arguments start with one or more filenames that you type at the What now? prompt. The last argument is the draft message pathname, which whatnow adds to the end of the command line.
If any of the first arguments match abbreviated names that are hard-coded into the script's case statement, those arguments are replaced with full pathnames of files. For example, the abbreviation sig on the command line will be replaced by the file .signature in your home directory. In the archived version of the script, these abbreviations are commented out; to use them, remove the comment characters. Of course, you can change these abbreviations and add other abbreviation lines. The while loop uses the Bourne shell's colon (:) operator. The colon operator returns a zero exit status. So, the while : always tests true -- and the loop keeps running until the case $# sees that there's only one argument left.
The list of files to append is stored in the files variable. After the while loop ends, if the user had typed a command line like this:
What now? e append file* $HOME/endthen $files would contain exactly file* $HOME/end. That's because the whatnow program doesn't expand wildcards or environment variables at its What now? prompt. To fix that, the script uses shell's eval command to reinterpret the command line -- in other words, to parse it twice.
The last line, exit 0, is important because an editor that returns nonzero status has "failed." By default, whatnow will delete a failed draft and quit. The Section Deleted Draft Messages explains more.
[Table of Contents] [Index] [Previous: Programs in This Book's Archive] [Next: Explanation of autoinc]
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 <firstname.lastname@example.org>