Path: utzoo!attcan!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!wuarchive!udel!princeton!cs!samadams!tr From: tr@samadams.princeton.edu (Tom Reingold) Newsgroups: comp.mail.mh Subject: Re: comp option addition request Keywords: comp, option, fcc, to, subject Message-ID: <5209@rossignol.Princeton.EDU> Date: 10 Dec 90 19:56:52 GMT References: <1990Dec4.203315.139@ux1.cso.uiuc.edu> <275C2953.28092@ics.uci.edu> Sender: news@cs.Princeton.EDU Organization: Noo Joizy -- The Cultural Mecca Lines: 123 In article <275C2953.28092@ics.uci.edu> jromine@ics.uci.edu (John Romine) writes: $ The answer is because you can do this with a shell script. We have $ resisted with medium to poor :-( success adding more switches to MH $ commands. Instead, we tried to give the MH commands more general $ functionality, which shell programmers could exploit. MH-format(5) $ is an example. $ $ Comp is designed to be used interactively. If you're looking for a $ programmatic way to send mail, look at "mhmail". $ $ Here's a partial shell script which does some of what you asked. You $ can easily fill in the other switches you want it to accept. You could $ also parse all of comp's arguments if you don't the requirement that $ "-subject" and "-fcc" come first. Abbreviations could be added as well. MH programs do a lot of things, and the beauty of it is that if you don't need a feature, it doesn't get in the way. Therefore, I don't see that it's important to resist adding new features, especially this particular feature which I suspect has a high demand. The answer "this can be done with a script" has two flaws: 1. People trust C programs more than scripts. 2. Just because it can be done doesn't mean it will. If it isn't distributed, some people will spin their own and others will do without. If a script really makes the most sense, and if this is really a generally desired feature, include the script with distribution. I use very few MH scripts because I don't need to in general, and doing so complicates my environment a lot. Mhmail is not a solution either because it does not use formfiles and is not extensible. It does not make fcc's, etc. You could argue that this feature should be a program by itself, separate from comp. I could go along with that. In any case, after all this hollering from me, here is my script. :-) If people are willing to beta test it, I would be willing to improve on it. I call it "mailh" for lack of ability to think of good names for programs. It works interactive *and* in batch! It reads your components file for a default form. #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # mailh # This archive created: Mon Dec 10 14:55:11 1990 # By: Tom Reingold (Noo Joizy -- The Cultural Mecca) export PATH; PATH=/bin:$PATH if test -f 'mailh' then echo shar: will not over-write existing file "'mailh'" else cat << \SHAR_EOF > 'mailh' #! /bin/sh if [ ! -f $HOME/.mh_profile ] then echo "Where is your .mh_profile?" exit 1 fi ADDRS='' SUBJ='' FORMF=/tmp/form.$$ subjnext=false for i in "$@" do if [ "$subjnext" = true ] then SUBJ=$i subjnext=false continue fi case $i in -s) subjnext=true ;; *) ADDRS="$ADDRS $i" ;; esac done if [ -z "`echo $ADDRS | sed 's/^ *//'" ] then echo "To whom are you sending mail?" exit 2 fi echo -n "To: " > $FORMF echo $ADDRS | sed 's/ /, /g' | fmt | sed '2,$s/^/ /' >> $FORMF tty -s TTY=$? if [ $TTY -eq 0 -o ! -z "$SUBJ" ] then echo Subject: $SUBJ >> $FORMF fi MHHOME=${HOME}/`grep "^Path:" $HOME/.mh_profile | awk '{print $2}'` egrep -v "^To:|^Subject:" $MHHOME/components >> $FORMF if [ $TTY -eq 0 ] then comp -form $FORMF else cat >> $FORMF send $FORMF fi SHAR_EOF if test 783 -ne "`wc -c < 'mailh'`" then echo shar: error transmitting "'mailh'" '(should have been 783 characters)' fi chmod +x 'mailh' fi # end of overwriting check # End of shell archive exit 0 -- Tom Reingold tr@samadams.princeton.edu OR ...!princeton!samadams!tr "Warning: Do not drive with Auto-Shade in place. Remove from windshield before starting ignition."