mh-skel - skeleton script for writing scripts to manipulate MH/NMH mail
mh-skel [options] <msg1> ... <msgN>
mh-skel is a skeleton script to assist in writing scripts that will
operate on mail messages stored in MH/NMH. It will not do anything itself,
but must be filled out with additional code to handle whatever functions are
The command-line-handling code will follow the description given in the
following section. That can, of course, be changed as required.
By default, the inbox mail folder will be searched for messages.
A mail folder may be specified on the command line by preceding the
folder name with a plus sign. For example, "mh-skel +papers 42" will
do something with message 42 in the papers mail folder.
Multiple mail folders may be given on a single command line, but only the
last folder will be used. Thus, "mh-skel +docs 42 +verbiage 88 +papers"
will not generate an error, but only messages 42 and 88 will be handled
in the papers folder.
AVAILABLE DATA AND ROUTINES
This section describes the global data and routines in mh-skel that
are used by the predefined routines, and may be used by routines created
for new MH/NMH scripts.
The following globals in mh-skel are used by the predefined routines,
and may be used by routines created for new MH/NMH scripts.
This is the name of the script.
This is the version string for the program. It is defined to be
"$NAME version: 1.0". Other than the version number, this should
not be changed.
This hash holds the options found on the command line.
This hash is a filled automatically by GetOptions().
This is a list of options that will be recognized by GetOptions().
See its man page to add additional options.
This is intended to be a boolean value that is set according to whether or
not the -verbose option is given. It is intended to be used to provide
information beyond the standard amount.
This is the default inbox folder name.
This is the path to the target NMH folder.
This is the path to the MH/NMH mail folder.
This is a hash of the messages to work on. The hash keys is the message
numbers. The hash value is the path to the message.
This list holds the "comma" messages (deleted messages) that were found
in argument list. These may not be used in all scripts.
This is the special hash key for the message-header hash that refers
to the message body. The default value is ' body ', and it shouldn't
ever be found as a mail header.
The following routines in mh-skel probably will need to be modified for
different utilities. They must be modified as required for each specific
MH/NMH helper script.
This parses the command line for options and arguments.
It must be modified as needed for command-specific options.
This routine examines the non-option arguments. This must be modified as
needed for command-specific arguments.
The skeleton code does the following:
- If there's a folder (marked by starting with a plus sign) we'll save the
name in the $mbox global. This assumes only one folder will be given
on a command line.
- Arguments that start with a comma are assumed to be deleted messages.
They will be saved in the @argcommas list.
- All other arguments are assumed to be message numbers or names. We'll use
the mhpath command to get their paths (and also shrink it to a list of
unique messages). These will be saved in the %msgs hash, with the
message number as the key and the message path as the value.
This routine is a more-specific driver routine.
The skeleton code does the following:
- Get the paths to the mail folder named in the $mbox mail folder.
- Calls readmsg() to read each individual message listed on the command
- Parse each message into a hash of message headers.
This routine does whatever must be done to a message. This is the super-duper
script-specific code. It must be modified for a new script; the
skeleton code doesn't really do anything.
The following routines in mh-skel probably do not need to be modified
for different utilities. However, they should be examined when creating a new
MH/NMH utility to ensure that this is true.
This is the main driver routine for the new utility.
It calls optsandargs() and processor().
Get the path to the MH folder named in $mbox.
Read a mail message and return its contents.
Parse a mail message's headers into a hash table.
This is a debugging routine that prints the header hash.
Give usage message and exit.
Print the version number(s) and exit.
You don't have to change this.
mh-skel takes the following options:
This option provides verbose information about the operation of mh-skel.
Display the version information for mh-skel.
Display a help message.
Wayne Morrison, firstname.lastname@example.org
Copyright 2014, 2017 Wayne Morrison
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.