procmail
[Top] [All Lists]

Re: Auto Subscription FINALLY!

1996-05-31 11:55:50
Gino Filicetti followed up,

| IF htere are any more cosmetic suggestions you think I should add (or
| delete), lemme know.. thanks a lot.. here it is...
| 
| rc.sub
| ~~~~~~
| VERBOSE=on
| :0
| * ^Subject: [cC][oO][cC] [Ss][uU][bB][sS][cC][rR][iI][bB][eE]*

First, without the `D' flag procmail considers all regexps to be case-
insensitive, so you didn't need to do all that.  Second, the trailing
asterisk at the end basically nullifies the `[eE]'; remember that we're
using regexps here, not shell globbing.  That condition should be

  * ^Subject: coc subscribe

| * !^X-Loop: ginof(_at_)io(_dot_)org
| * !^Subject:.*Re:
| * !^FROM_DAEMON
| {
|    FROM_ADDRESS=`formail -rxTo: | cut -c2-`

Why are you calling cut?  To get rid of the initial space?  Just use
formail's -z option:

     FROM_ADDRESS=`formail -rzxTo:`

That saves calling cut *and* calling a shell to handle the piping from
formail to cut.  Better yet, reduce the feed to formail to only the head:

    :0h
    FROM_ADDRESS=| formail -rzxTo:

|    :0hw
|    * ^Subject: coc subscribe \/[^ ]*
|    {
|       NAME=`echo "$MATCH" | cut -c1-25`
|    }

You're running a shell and cut but don't need to.  If something is possible
within procmail, it's more efficient not to fork other programs.  Also, the
`h' and `w' flags meaningless when you aren't saving to a folder or feeding
to a pipe, so you can leave them off:

      :0
      * ^Subject: coc subscribe \/[^ ]*
      { NAME=$MATCH

        :0 # twenty-five dots
        * NAME ?? ^^\/..........................
        { NAME=$MATCH }
      }


|    :0
|    * NAME ?? .
|    { NAME = "$NAME" }
| 
|    :0E
|    { NAME=$FROM_ADDRESS }

There's no need to set $NAME to the value it already has.  Just do this:

     :0
     * ! NAME ?? .
     { NAME=$FROM_ADDRESS }

I still question whether you don't want to truncate to twenty-five characters
*after* filling in $FROM_ADDRESS if $NAME was empty.  What if $FROM_ADDRESS
is too long?

<Prev in Thread] Current Thread [Next in Thread>