procmail
[Top] [All Lists]

Re: Auto Subscription FINALLY!

1996-06-03 09:48:27
Gino Filicetti had asked,

| > | ... [H]ow do I trim ANY whitespace from the beginning OR end of $NAME?

And I offered,

| >    :0
| >    * NAME ?? \\/[^  ].*[^   ]
| >    { NAME=$MATCH }
| > where the two sets of brackets each enclose a caret, a space, and a tab.

to which Gino responded,

| No, that didn't work... when I tried it, a verbose log told said there was
| NO MATCH for that condition, so I dont' know, it was one spc and one tab
| for sure, but no go...

If $NAME contains at least two characters that are not spaces and not tabs,
then there should be a match.

[Gino wanted to accept the command in either the subject line or the body.]

| > You required it at the beginning of the line if it's in the body, so
| > something like this would work:
| >    :0
| >    * 2147483647^0 ^Subject: coc subscribe
| >    * 1^0 B ?? ^coc subscribe
| >    { actions on success }
| 
| Ok, this is VERY confusing, can you explain to me what these numbers
| mean??

Read the procmailsc(5) man page.  It's explained in there.

| > It may be easier to write this way:
| >    :0
| >    * ! ^Subject: coc subscribe
| >    * ! B ?? ^coc subscribe
| >    { }
| >    :0E
| >    { actions on success }

| ... [W]hat do we do
| about getting the $NAME variable set, since we are using a line like this:
| 
|    :0
|    * ^Subject: coc subscribe \/[^ ]*
|    { NAME=$MATCH
|      :0 # twenty-five dots
|      * NAME ?? ^^\/.........................
|      { NAME=$MATCH }
|    }
| 
| How do we work around this? Difficult eh?

Not difficult at all.  The negated conditions, since their expressions match,
will still set $MATCH, even though (being negated) they fail as conditions:

   :0
   * !^Subject: coc subscribe *\/[^ ].*
   * ! B ?? ^coc subscribe *\/[^ ].*
   :0E
   {
     NAME=$MATCH

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

Note that if an incoming message has "coc subscribe name" in the subject and
again in the body, the name given in the subject will prevail.

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