I hate to experiment when I have folders full of important mail. I've made another MH directory named Mail_test. It has a duplicate set of files like replcomps, some folders with useless messages, and so on.
Whenever I want to test commands, I edit my MH profile and change the Path: entry to read:
Path: Mail_testUntil I change that entry back, MH commands use my Mail_test directory.
If I inc some messages that I want to keep, I just refile them into my "real" MH directory with a command like:
% refile +$HOME/Mail/inboxand read them after I change the Path: back.
Another way to change your MH setup is by defining the MH environment variable. If it's defined, MH will use it as the location of the MH profile file -- otherwise, MH defaults to .mh_profile in your home directory. You can make an MH profile with a name like tmpMHprofile in your home directory and set MH to $HOME/tmpMHprofile.
CAUTION: Some versions of xmh ignore the MH environment variable. See the Section Conflicts Between xmh and MH Customization for a workaround.
An easy way to make test messages is by linking to one message over and over. This is easiest if you create a test folder, then change your shell's current directory to it. After that, use cp to copy in a test message from some other folder. For example, to copy message number 100 from inbox into a new test folder:
% folder +test Create folder "/yourMHdir/test"? y % cd `mhpath +test` % pwd /yourMHdir/test % cp `mhpath cur +inbox` 100 % scan 100 100 04/01 Steven Dommer Re: meeting minutes<<> A while bBe sure not to link (ln) this first message to the other folder. Use cp as shown above. That's because any changes you make to a link will appear in the original message too!
Now you're ready to make your links to this test message. The easiest way is with a shell loop (the Section Sorting Messages: sortm has another example). Each shell has a different way to do this; for the C shell, see the next Example.
Example: C shell loop to make 100 test
% @ num=1 % while ($num < 100) ? ln 100 $num ? echo made link $num ? @ num++ ? end made link 1 ... made link 99 %The at sign (@) operator in the Example above is the C shell's way of doing arithmetic. The command line @ num=1 sets $num to 1, and @ num++ increments $num by one. The loop makes the first link, adds 1 to num, then tests to see if $num is still less than 100.
The links save filesystem space. If you want individual copies instead of links, though, use cp instead of ln.
The standard Bourne shell doesn't have built-in arithmetic. To speed things up, the Example below shows a tricky way to get numbers from the Bourne shell without addition. This set of nested loops does the same thing as the C shell loop above. They're indented for clarity.
Example: Bourne shell nested loop to make
100 test messages
$ for t in "" 1 2 3 4 5 6 7 8 9 > do > for o in 0 1 2 3 4 5 6 7 8 9 > do > ln 100 $t$o > echo made link $t$o > done > done made link 0 made link 1 ... made link 99 $ rm 0The loop in the Example above is a little messy, and the echo command will slow it down if your shell doesn't have echo built in. It has an outer loop that sets $t, the "tens" place. The inner loop sets $o, the "ones" place. The loops are messy because they create a link named 0 which MH won't like; you can remove it with rm 0.
This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. It is freely available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see COPYING.
Copyright © 1991, 1992, 1995 O'Reilly Media, Inc.
Copyright © 1996, 1997, 1998, 1999, 2000, 2002, 2004 Jerry Peek
Last modified: 2006-05-31 15:13:43 -0700