Re: procmailrc syntax
Klaus Johannes Rusch <[email protected]> Fri, 28 Oct 2016 23:21:51 +0200
| Newsgroups | gmane.mail.procmail |
|---|---|
| Message-ID | <[email protected]> |
On 2016-10-28 22:07, Zhiliang Hu wrote:
> Although I used procmail for so long I never figure out what kind of =
> "script" rules it follows. For example in one of my rc script I try =
> to calculate a list file ("dist"):
>
> DISTCOUNT=3D`grep -cv '^(' dist` -1
>
> the calculation part fails, end up in the log:
>
> procmail: Skipped "-1"
>
> How can I get over this without getting it to external script for a =
> simple calculation like this?
From procmailrc(5):
The assignments and substitutions of these environment
variables are handled exactly like in sh(1) (that includes
all possible quotes and escapes), with the added bonus
that blanks around the '=3D' sign are ignored and that, if
an environment variable appears without a trailing '=3D', it
will be removed from the environment. Any program in
backquotes started by procmail will have the entire mail
at its stdin.
Complete with safeguards against an empty grep result:
sh -c "VAR1=3D`grep -cv '^(' dist`;let DISCOUNT=3D${VAR1:-0}-1"
-- =
Klaus Johannes Rusch
[email protected]
http://klausrusch.atmedia.net/