[comp.mail.mh] comp option addition request

daniel@ux1.cso.uiuc.edu (Daniel Pommert) (12/05/90)

This is a request for comments on the idea of adding the -fcc flag, as
it appears on repl to the comp command.  In a similar vein, I feel that
it would be nice if the -to and -subject options would be added to
comp.  The components file would need to be parsed in a similar way to
replcomps so that the existence of %{fcc}, %{to} and %{subject} could
be properly handled.

Comp could then be placed in an alias which would allow its use as a
pleasant mix of Berkeley mail and comp.  mhmail does not provide this
functionality.

Is there any other way of doing this presently with mh?  Was there some
important reason that these options are not already present in comp?

-- 
-- Daniel Pommert
email.internet:	pommert@uiuc.edu	email.bitnet:	daniel@uiucvmd
phone:	(217) 333-8629
post:	DCL MC-256; 1304 W. Springfield; Urbana, IL  61801-2987

jromine@buckaroo.ics.uci.edu (John Romine) (12/05/90)

daniel@ux1.cso.uiuc.edu (Daniel Pommert) writes:
>This is a request for comments on the idea of adding the -fcc flag, as
>it appears on repl to the comp command.  In a similar vein, I feel that
>it would be nice if the -to and -subject options would be added to
>comp.  The components file would need to be parsed in a similar way to
>replcomps so that the existence of %{fcc}, %{to} and %{subject} could
>be properly handled.
>
>Is there any other way of doing this presently with mh?  Was there some
>important reason that these options are not already present in comp?

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.

/JLR

: This is a shar archive.  Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
echo 'Extracting mycomp'
sed 's/^X//' > mycomp << '+ END-OF-FILE mycomp'
X#! /bin/sh
Xwhile :
Xdo
Xcase x$1 in
X  x-subject) shift; sub=$1;;
X  x-fcc) shift; fcc=$1;;
X  *) break;;
Xesac
Xshift
Xdone
X
Xsed -e "/Subject:/s/\$/ ${sub}/" \
X    -e "/Fcc:/s/\$/ ${fcc}/" <<EOF >/tmp/mycomp.$$
XTo:
Xcc:
XFcc:
XSubject:
X--------
XEOF
X
Xcomp -form /tmp/mycomp.$$ $*
Xrm -f /tmp/mycomp.$$
+ END-OF-FILE mycomp
chmod 'u=rwx,g=rx,o=rx' 'mycomp'
echo '	-rwxr-xr-x  1 jromine       290 Dec  4 14:52 mycomp        (as sent)'
echo -n '	'
/bin/ls -l mycomp
exit 0
--
John Romine

tr@samadams.princeton.edu (Tom Reingold) (12/11/90)

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."

jromine@buckaroo.ics.uci.edu (John Romine) (12/11/90)

>jromine@ics.uci.edu (John Romine) writes:
> 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.

tr@samadams.princeton.edu (Tom Reingold) writes:
>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.

Actually, it is a problem.  The problem is the way people interact with
systems.  Trying to keep the MH programs simple, yet still give advanced
users the ability to customize the system is the goal.   Achieving it is
difficult.

I have difficulty getting non-computer-programmers (i.e., computer
users) to learn MH because of the existing complexity.  Novice MH users
look at the long list of options available to each command, and the
thickness of the MH user's manual, and give up trying to learn to use MH.

If writing a script to perform a new MH function seems very awkward,
then there is likely some change needed to the existing MH command
set.  If this is not the case, then I'm reluctant to add new options
onto an MH command unless most MH users are going to make use of those
option.

In the future, look for "repl" and "forw" to merge into one program
(like show, next & prev are).  That program should have the functions
that have been asked for.

BTW, I am happy to accept new programs or scripts for inclusion in
the MH distribution as user-contributed software.  Just send them to
Bug-MH@ics.uci.edu.  Please include a README file describing what the
program does, and who to contact about problems.

/JLR
--
John Romine