Running an MH Command

This section explains what happens when you run an MH command, step by step. (This also applies when a front-end runs an MH command for you.)

To help with the explanation, assume that you type the command:

    % scan -noheader picked +inbox
    
and that your MH profile has the entry:
    scan: -form scan.size -header
    
The steps are:
  1. UNIX searches for the scan program file and starts it running.
  2. One of the first things scan does is to find the MH profile file. The Path: entry in the MH profile has the name of your MH directory. (The MH directory is usually named Mail. The Section Changing MH Directory Name has more information.)
  3. The command checks your MH profile for entries with the exact command name. The settings in this entry override the default scan settings. In this example, for instance, the -form scan.size overrides scan's default format. Also, scan defaults to -noheader, but the -header in your MH profile overrides that default. So now, by default, scan will print a heading over the listing.
  4. Command-line parameters (-noheader picked +inbox) are read. Any switches override the corresponding default and MH profile switches. So in this example, -noheader wins the "battle of the switches" and will be used when scan runs.

    Some arguments can't be used more than once. For instance, if you store this entry in your MH profile:

          inc: +somefolder
          
    and also give a folder name on the command line, this happens:
          % inc +otherfolder
          inc: only one folder at a time!
          
  5. The command looks in your MH directory for the file named context. This is where your current folder name and some other information are stored (see your online mh-profile(5) manual page).
  6. The command looks in your folder for the .mh_sequences file. This file holds the message number sequences like cur (the current message number) and, in this example, picked.
  7. The command scans and displays your folder.
  8. If the command succeeds, it changes the current folder and current message (if needed). Commands like:
          % show 1234 +inbox
          
    usually won't change the current folder to inbox, or the current message to 1234, if there isn't a message number 1234 in the inbox.