procmail
[Top] [All Lists]

Questions Re: Some date checking code.

2003-05-25 07:00:57

It's been a while since this has been posted, but I've been busy and 
have wanted to try to work this out on my own. I still have some 
questions.

DATE_SECS
TODAY_SECS

This is probably such an obvious thing to most, and I'm probably 
making this harder than I should. Do these two lines create two 
variables with no values attached? If so, is this for clarity (ie 
these lines could be dropped with no problem, the variables being 
initialized at the same time that they are set further down in the 
script)?

:0 H
* ^Date:[       ]+\/.*

This puts everything after the whitespace (any number of spaces or 
tabs) into the variable MATCH, which effectively puts the content of 
the Date: header into that variable.

{
   DATE_SECS=`date --date "$MATCH" +%s`

This uses the date function to describe the time specified in the 
Date: header, formatting it to include the seconds, and saving it in 
the variable DATE_SECS.

   TODAY_SECS=`date +%s`

This gives the variable $TODAY_SECS the current date information, 
formatted to include the seconds.

All of this is preliminary to actually checking the filtering.

}
DATE_SECS=${DATE_SECS:-"Bad date"}

I'm stuck on this line. It is changing the value of the variable 
DATE_SECS? What do the curly brackets do? (Again, I have a feeling 
that this is pretty simple, but I'm stuck.)


:0 H
* DATE_SECS ?? [^0123456789]

This line matches DATE_SECS against any character which is not a 
single digit?

{
   :0 H
   * $ ${WEIGHT}^0

I'm lost here. The first '$' tells procmail to evaluate the remainder 
of the condition according to sh substitution rules inside double 
quotes. But it looks like a scoring recipe. And there are those curly 
brackets again.

   * 6^0

A standard scoring recipe, giving 6 to the first instance, 0 to each 
following instance.

   { }

??

   WEIGHT="$="

This sets the value of the variable WEIGHT to the final score ($=).

   LOG="Weight adjusted for bad date: $WEIGHT $NL"
}

This logs the results, writing the value of WEIGHT and a newline (I 
assume that this has been set somewhere else, but it is a convention 
I recognize.

Doug


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