procmail
[Top] [All Lists]

Re: Auto Subscription FINALLY!

1996-05-31 13:20:28
| * ^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

Alright, I'll change that... thanks a lot...

| * !^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:

Ok, so if I use the pipe as you suggested I'd save invoking a shell? but
doesn't a shell need to be invoked to run formail anyways? Also, I don't
think my formail has a -z option (unless it's undocumented) I have an
unknown version of formail and it doesn't have a man page, but typing
formail -h brings up a list of options and -z isn't there....

|    :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 }
      }

I don't like the idea of using the dots.... what if the variable is less
than 25 what happens???  and if it's null??

|    :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 }

Shit, how could I miss that... thanks..... how much difference does it
make taking out all this redundant stuff?

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?

No no... the addresss has to stay intact or else how could I put it on my
mailing list?? no, address can be as long as possible, EVEN when it's
subbed into $NAME....


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