procmail
[Top] [All Lists]

Re: Braced block and $=

2001-05-17 16:39:13

Thanks, Philip. But it does not work as per the MISCELLANEOUS:

    :0
    * -11^0
    * 4^0 something
    * 4^0 somethingelse
    * 4^0 andanother
    * 4^0 andsomeother
    {
        # do something if total >= 11
    }
    #
    :0
    * 8^0
    * $$=^0
    {
        # do something if total was >= 8
    }

$$=^0 is always zero at the beginning of the second block, and the
second block always executes. (Although your recomendations do work.)

        John

Philip Guenther writes:
John Conover <conover(_at_)rahul(_dot_)net> writes:
There might be a bug in the way $= is handled if a receipe executes
a block:

   :0
   * -11^0
   * 4^0 something
   * 4^0 somethingelse
   * 4^0 andanother
   * 4^0 andsomeother
   {
       # do something if total >= 11
   }
   #
   :0
   * 8^0
   * $$=^0
   {
       # do something if total was >= 8
   }

The log indicates that $$=^0 is *_always_* zero. However:
...
Can anyone else verify this?

This behaviour is documented on the procmailsc(5) manpage:

MISCELLANEOUS
       You can query the final score of all the conditions  on  a
       recipe from the environment variable $=.  This variable is
       set every time just after procmail has parsed  all  condi-
       tions  on  a  recipe (even if the recipe is not being exe-
       cuted).


You'll need to save the score in another variable across the block:

      :0
      * -11^0
      *   4^0 something
      *   4^0 somethingelse
      *   4^0 andanother
      *   4^0 andsomeother
      { }
      SCORE = $=

      :0
      * $$SCORE^0
      {
              # do something if total >= 11
              # Maybe even set SCORE in here to something else?
      }

      :0
      * 8^0
      * $$SCORE^0
      {
              # Do something if SCORE > -8
      }


Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail
-- 

John Conover        Tel. 408.370.2688  conover(_at_)rahul(_dot_)net
631 Lamont Ct.      Fax. 408.379.9602  http://www.johncon.com/
Campbell, CA 95008  Cel. 408.772.7733  

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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