procmail
[Top] [All Lists]

Re: Questions Re: Some date checking code.

2003-05-25 08:33:20
On Sun, 25 May 2003, Doug Essinger-Hileman wrote:

DE>
DE> It's been a while since this has been posted, but I've been busy and
DE> have wanted to try to work this out on my own. I still have some
DE> questions.
DE>
DE> > DATE_SECS
DE> > TODAY_SECS
DE>
DE> This is probably such an obvious thing to most, and I'm probably
DE> making this harder than I should. Do these two lines create two
DE> variables with no values attached?

No. it removes the variables


DE>  If so, is this for clarity

No, it is so that they can be tested for non-existance

DE>
DE> All of this is preliminary to actually checking the filtering.
DE>
DE> > }
DE> > DATE_SECS=${DATE_SECS:-"Bad date"}
DE>
DE> I'm stuck on this line. It is changing the value of the variable
DE> DATE_SECS? What do the curly brackets do? (Again, I have a feeling
DE> that this is pretty simple, but I'm stuck.)
DE>

From the Bash man page:

${parameter:-word}
              Use Default Values.  If parameter is unset or null,
              the expansion of word is  substituted.   Otherwise,
              the value of parameter is substituted.



DE> >
DE> > :0 H
DE> > * DATE_SECS ?? [^0123456789]
DE>
DE> This line matches DATE_SECS against any character which is not a
DE> single digit?
DE>

Yes.  So it would throw a wobbly if the DATE_SECS contained "bad date"


DE> > {
DE> >    :0 H
DE> >    * $ ${WEIGHT}^0
DE>
DE> I'm lost here. The first '$' tells procmail to evaluate the remainder
DE> of the condition according to sh substitution rules inside double
DE> quotes. But it looks like a scoring recipe. And there are those curly
DE> brackets again.


Up until now you've used very similar code to to the code I use. WEIGHT is
new. You have missed out the recipe to assign something to WEIGHT.  Yes,
it looks like it is used in scoring to do arithmetic.

I suspect you have something similar to mine:

  # Check for future date
  # 5 days = 432,000 secs
  :0 E
  * $  ${DATE_SECS} ^ 0
  * $ -${FROM_SECS} ^ 0
  *   -432000 ^ 0
  {

where I compare the date: field date with date when the message actually
arrived.  It goes positive when the email is 5 days in the future.  When
it is positive, the action block, anything after the {, is executed.

Sean B. Straw is a "weight" man I think so you are probably looking at
some of his recipes.  My recipes are all yes/no ones.


Alan


( Please do not email me AS WELL as replying to the list.  Please
  address personal email to alan+1@ as lists@ is not read. A
  password autoresponder may be invoked if this email is very old. )


_______________________________________________
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>