[comp.mail.mh] how to overide .mh_profile values

qq11@uxb.liverpool.ac.uk (Alan Thew) (04/19/91)

I was looking at Jerry Peek's recomp shell script, making a few
changes (pick up draft folder whatever its name etc) and found it
very useful. A problem occurs with my understanding of .mh_profile
values vs options on the command line, for example:

...........
$mh/comp -use -e ${VISUAL-${EDITOR-${EDIT-vi}}} -draftm $msgnum 
#$mh/comp -use -e ${VISUAL-${EDITOR-${EDIT-vi}}} -draftm $msgnum -draftf $draftf
stat=$?   # SAVE comp'S STATUS (IT'S USUALLY 0) FOR OUR exit

These are the last lines in the script (the first here was 'added' by
me). If line 2 is used, the following message appears when comp starts: 

comp: only one draft folder at a time

My .mh_profile entry for comp is:

comp: -editor prompter -draftfolder +draftings

I assumed that use of a switch on the command line overrode the profile
value, but both appear to being used!

What am I doing wrong here or what assumptions should I not have made?
Thank you.

version: MH 6.7.1 #3[UCI] (uxb) of Sat Mar 9 03:48:33 GMT 1991
options: [BSD42] [ATZ] [BSD43] [MHRC] [SUN40] [UK] [SENDMTS] [SMTP]

-- 
 
      Alan Thew : University of Liverpool Computer Laboratory
Internet/Bitnet : qq11@uxb.liv.ac.uk
         UUCP   :           ....!mcsun!ukc!liv-uxb!qq11
        Voice   :  +44 51 794 3735        FAX : +44 51 794 3759

jerry@ORA.ORA.COM (Jerry Peek) (04/21/91)

[This is sort of long, but it has some interesting MH philosophy and tidbits...
not much about shell programming.]

In message <19280.9104191603@uxb.liv.ac.uk>, Alan Thew wrote:
> I was looking at Jerry Peek's recomp shell script, making a few
> changes (pick up draft folder whatever its name etc) and found it
> very useful.

For people who don't have the script, it hardcodes the folder name at the top:
	draftf=+drafts
and passes it into the command line that Alan mentioned:
	$mh/comp -use -e <editor> -draftm $msgnum -draftf $draftf

The script doesn't need to set $draftf if the MH profile has an entry like:
	Draft-folder: drafts
I've never used a "comp: -draftfolder +drafts" in my MH profile like Alan...
I've always used "Draft-folder: drafts"... so I didn't catch that problem.
But then Alan brings up an interesting point... some MH behavior that could
be a feature or a bug, depending on how you look at it:

> I assumed that use of a switch on the command line overrode the profile
> value, but both appear to being used!

When MH gets the user's settings, it first reads the MH profile and then
reads the command line.  There's usually a difference between the way MH
treats switches like "-use" (which can be either "on" or "off") and folder
names.  The code that reads boolean switches is happy with conflicting
settings -- the last switch setting it finds "wins."  But in most cases,
the code for folder names complains if it finds a total of more than one
folder.  Sometimes that's good because it catches mistakes like:
	% folder +a +b
and for most commands, a default folder in the MH profile would be silly.
But MH does allow default folders in the profile sometimes -- for example,
	refile: +default_folder
makes +default_folder get a link to *all* messages you refile -- as in:
	% refile +foo
the current message would be refiled into both +default_folder and +foo.

You can override the following profile component:
	Draft-folder: drafts
with a "-draftfolder +foo" in the profile or on the command line. 
The question is: should "comp" and other MH commands allow the command
line to override profile entries like "comp: -draftfolder +foo"?
Or does anybody really care?? :-)

--Jerry Peek, jerry@ora.com or uunet!ora!jerry

P.S.  The C code for setting a draft folder is simple enough.  In uip/comp.c,
there's a loop that reads values from the MH profile and the command line.
When it finds "-draftfolder", it checks the variable where the draft folder
name is stored.  If dfolder is already set, adios() screams and exits:
    case DFOLDSW:
        if (dfolder)
            adios (NULLCP, "only one draft folder at a time!");
        if (!(cp = *argp++) || *cp == '-')
            adios (NULLCP, "missing argument to %s", argp[-2]);
        dfolder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
                *cp != '@' ? TFOLDER : TSUBCWF);
        continue;
This shouldn't be hard to change: just get rid of the first two lines, eh??