Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I use <a href="http://www.procmail.org/" rel="nofollow noreferrer">procmail</a> to sort my incoming email to different folders. Because I have trouble remembering the procmailrc syntax, I use <a href="http://www.gnu.org/software/m4/" rel="nofollow noreferrer">m4</a> as a preprocessor. Here's how my procmailrc begins (this isn't the script yet):</p> <pre><code>divert(-1) changequote(&lt;&lt;, &gt;&gt;) define(mailinglistrule, &lt;&lt;:0: * $2 Lists/$1 &gt;&gt;) define(listdt, &lt;&lt;mailinglistrule($1,^Delivered-To:.*$2)&gt;&gt;) define(listid, &lt;&lt;mailinglistrule($1,^List-Id:.*&lt;$2&gt;)&gt;&gt;) divert# Generated from .procmailrc.m4 -- DO NOT EDIT </code></pre> <p>This defines two macros for mailing lists, so e.g. listdt(foo, foo@example.com) expands to</p> <pre><code>:0: * ^Delivered-To:.*foo@example.com Lists/foo </code></pre> <p>meaning that emails with a Delivered-To header containing foo@example.com should be put in the Lists/foo folder. It also arranges the processed file to begin with a comment that warns me not to edit that file directly.</p> <p>Now, frankly, m4 scares me: what if I accidentally redefine a macro and procmail starts discarding all my email, or something like that? That's why I have a script, which I call update-procmailrc, that shows me in diff format how my procmailrc is going to change. If the change is just a few lines and looks roughly like what I intended, I can happily approve it, but if there are huge changes to the file, I know to look at my edits more carefully.</p> <pre><code>#! /bin/sh PROCMAILRC=.procmailrc TMPNAM=.procmailrc.tmp.$$ cd $HOME umask 077 trap "rm -f $TMPNAM" 0 m4 &lt; .procmailrc.m4 &gt; $TMPNAM diff -u $PROCMAILRC $TMPNAM echo -n 'Is this acceptable? (y/N) ' read accept if [ -z "$accept" ]; then accept=n fi if [ $accept = 'y' -o $accept = 'Y' ]; then mv -f $TMPNAM $PROCMAILRC &amp;&amp; \ chmod 400 $PROCMAILRC &amp;&amp; \ echo "Created new $PROCMAILRC" if [ "$?" -ne 0 ]; then echo "*** FAILED creating $PROCMAILRC" fi else echo "Didn't update $PROCMAILRC" fi </code></pre> <p>The script hasn't yet prevented any email disasters, but it has made me less anxious about changing my procmailrc.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload