procmail
[Top] [All Lists]

Re: Auto Subscription FINALLY!

1996-05-31 15:33:05
| > | 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....
| > You can still get around it:
|
| It would seem I don't need too... I tried it out, and it works fine..

Procmail might be stripping leading and trailing whitespace in assigning the
variable.

| > | >         :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??
| > If $NAME is null, unset, or shorter than twenty-five characters, then the
| > condition doesn't match, so the code in the braces is skipped, and $NAME is
| > left at its previous value, exactly as you want.

| Alright, this worked as well, just you had one too many dots because
| '1234567890123456789012345thisisextra' was truncated to:
| '1234567890123456789012345t', but I'll fix that...

Yup, so I did.  Sorry.

| but perhaps you can
| answer me this.. how do I trim ANY whitespace from the beginning OR end of
| $NAME?

Well, ...

   :0
   * NAME ?? \\/[^      ].*[^   ]
   { NAME=$MATCH }

where the two sets of brackets each enclose a caret, a space, and a tab.
Remember that to the right of the extraction operator procmail looks for
the *longest* possible match.  You need the extra backslash to protect
the first one; otherwise an initial backslash would just escape the fore-
slash instead of forming an extraction operator.

| ... have you seen my other post yet about getting the 'coc subscribe'
| request from EITHER the body or subject?? how would I go about that?

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 }

It may be easier to write this way:

   :0
   * ! ^Subject: coc subscribe
   * ! B ?? ^coc subscribe
   { }
   :0E
   { actions on success }

To be thoroughly vicious, one can do this, but it is hard to proofread and
maintain:

   :0HB
   * ^^(.+$)*(Subject: |$(.*$)*)coc subscribe
   { actions on success }

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