NAME
mh-skel - skeleton script for writing scripts to manipulate MH/NMH mail
messages
SYNOPSIS
mh-skel [options] <msg1> ... <msgN>
DESCRIPTION
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
required.
The command-line-handling code will follow the description given in the
following section. That can, of course, be changed as required.
MAIL FOLDERS
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.
Globals
The following globals in mh-skel are used by the predefined routines,
and may be used by routines created for new MH/NMH scripts.
- $NAME
This is the name of the script.
- $VERS
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.
- %opts
This hash holds the options found on the command line.
This hash is a filled automatically by GetOptions().
- @opts
This is a list of options that will be recognized by GetOptions().
See its man page to add additional options.
- $verbose
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.
- $INBOX
This is the default inbox folder name.
- $mbox
This is the path to the target NMH folder.
- $folderpath
This is the path to the MH/NMH mail folder.
- %msgs
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.
- @argcommas
This list holds the "comma" messages (deleted messages) that were found
in argument list. These may not be used in all scripts.
- $BODYKEY
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.
Utility-Specific Routines
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.
- optsandargs()
This parses the command line for options and arguments.
It must be modified as needed for command-specific options.
- peekargs()
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.
- processor()
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
line.
- Parse each message into a hash of message headers.
- msghandler()
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.
Utility-Common Routines
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.
- main()
This is the main driver routine for the new utility.
It calls optsandargs() and processor().
- getdirs()
Get the path to the MH folder named in $mbox.
- readmsg()
Read a mail message and return its contents.
- parsemsg()
Parse a mail message's headers into a hash table.
- printhdrs()
This is a debugging routine that prints the header hash.
- usage()
Give usage message and exit.
- version()
Print the version number(s) and exit.
You don't have to change this.
OPTIONS
mh-skel takes the following options:
- -verbose
This option provides verbose information about the operation of mh-skel.
- -Version
Display the version information for mh-skel.
- -help
Display a help message.
AUTHOR
Wayne Morrison, wayne@waynemorrison.com
LICENSE
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
http://www.apache.org/licenses/LICENSE-2.0
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.
SEE ALSO
nmh(1),
mhpath(1)
Getopt::Long(3)