On Tue, 29 Apr 1997 12:46:35 +0200 (MET DST),
"Pascal A. Dupuis" <dupuis(_at_)lei(_dot_)ucl(_dot_)ac(_dot_)be> wrote:
- a variable is initialised as
CPDOM1=`cat $HOME/filters/cpdomains.1 | tr '\012' '|'`
whose output is (Solaris 2.5)
ispam.com|ispam.net|
(That is, the last character is also translated)
<...>
Doing the substitution, the last condition is empty, wich seems to matches
anything !
How could I avoid it ( I don't figure how to remove the last char from a
pipe)
Don't do the tr like that in the first place, or make sure the file
doesn't have a trailing newline. Alternatives to tr include sed, perl,
and awk; each of those have more capabilities and should perform
nicely.
(If your sed understands \n for newline, you could use
sed -e 'y/\n/|/' -e 's/\|$//'
but many seds want bare newlines which is sort of ugly and a bit
tricky in a Procmail action line.)
? Does more recents version of procmail treat this last | followed
by nothing as something which could be ignored rather than a catchup
rule ?
No; generally, you want to avoid "special cases" in programming
languages unless there is a very good reason to have them. (You could
argue that || is always bound to be used by mistake but then you rule
out the possibility to match an empty string, ever. Or then you have
to devise yet another special case for when you do want to match an
empty string. It becomes cumbersome and inelegant.)
This is used within a rule :
:0: cyberpromo
* $^(From|To|Received|Reply-to|X-Sender|Sender):.*(${CPDOM1})
$TRASH
Less kludgy solutions come to mind, but how about simply:
:0:
* $ ^(From|To|Received|Reply-to|X-Sender|Sender):.*(${CPDOM1}@@@@)
$TRASH
That is, just add some unlikely string to "fill up" after the |
operator. (This will expand to "ispam.com|ispam.net|...|@@@@".)
Hope this helps,
/* era */
(You don't have a good reason for using a named lock file on that
particular recipe, do you?)
--
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r. <http://www.iki.fi/~era/>
* Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>