[comp.mail.mh] rmm[proc] replacement

marvit%hplpm@HPLABS.HP.COM (Peter Marvit) (06/28/88)

Continuing the drift, the "aliasing" of rmm is fine for csh and ksh folks
who execute MH only from the shell, but unfortunately won't work for the
programmatic interfaces and various uses of rmmproc.  The most general
solution I've come up with so far is this.  Combine with the previous
unrmm's and you're cooking with gas...

OK, here's my proven solution (tested for at least one hour).  In your
.mh_profile, include the line:

	rmmproc: /users/marvit/bin/my-rmm

or some suitable pathname to the following shell script:

-------------------------------CUT HERE------------------------------
:
# my-rmm.  The : at the beginning forces /bin/sh.  This version puts all
# deleted messages into the +wastebasket folder.  Be sure to expunge with
#      rm `mhpath +wastebasket`
# every so often

until [ -z "$1" ]
do
	/bin/mv $1 `mhpath +waste new`
	shift
done
-------------------------------END HERE------------------------------

If you just wanted to use a new name in the same folder, edit the following
script to use your favorite prefix, if you don't like "#" or "," as the
prepended "deleted" character:

-------------------------------CUT HERE------------------------------
:
# my-rmm.  The : at the beginning forces /bin/sh.  This version puts all
# deleted messages into the +wastebasket folder.  Be sure to expunge each
# folder with 
#      rm `mhpath`/.D
# every so often.  In fact, you could loop thourgh all the folders, with the
# script mh-expunge 

PREFIX=.D.

until [ -z "$1" ]
do
	/bin/mv $1 `dirname $1`${PREFIX}`basename $1`
	shift
done
-------------------------------END HERE------------------------------

And this may be your mh-expunge:

-------------------------------CUT HERE------------------------------
:
# mh-expunge. The : at the beginning forces /bin/sh.  Be sure that the
# $PREFIX is the same as in my-rmm.

PREFIX=.D.

for folder in `folders -fast -all -recurse -noheader -nototal -nopack -print`
do
	rm `mhpath +folder`/${PREFIX}*
-------------------------------END HERE------------------------------

Voila, you are ready to conquer the world.  Note, however, that "rmm" will
also execute "my-rmm" so that if you try to do a "rmm +wastebasket all",
you'll just copy all the messages to a higher number.

This solution appears to work both from within programs which need rmmproc
and from the shell.  Added bonus: This way forms like "rmm all" and "rmm 3
5 6" work properly!

-Peter Marvit
 HP Labs

allbery@ncoast.UUCP (Brandon S. Allbery) (07/05/88)

As quoted from <22799.583436802@hplpm> by marvit%hplpm@HPLABS.HP.COM (Peter Marvit):
+---------------
| OK, here's my proven solution (tested for at least one hour).  In your
| .mh_profile, include the line:
| 
| 	rmmproc: /users/marvit/bin/my-rmm
| 
| or some suitable pathname to the following shell script:
| 
| until [ -z "$1" ]
| do
| 	/bin/mv $1 `mhpath +waste new`
| 	shift
| done
+---------------

May I suggest that a relatively minor change will allow for "rmm +waste ..."
to work in a more useful way?

folder -push -nolist		# can these two lines
folder -noprint +waste		# be combined?
here=`mhpath`
until [ -z "$1" ]; do
	if [ "`basename \"$1\"`" = "$here" ]; then
		rm "$1"
	else
		mv "$1" "`mhpath new`"
	fi
done
folder -pop -nolist

This should (not tested, but should be close) arrange to delete the message
if and only if it is already in +waste; otherwise, it is moved to +waste.
-- 
Brandon S. Allbery, uunet!marque!ncoast!allbery			DELPHI: ALLBERY
	    For comp.sources.misc send mail to ncoast!sources-misc