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=`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 '=' sign are ignored and that, if
an environment variable appears without a trailing '=', 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=`grep -cv '^(' dist`;let DISCOUNT=${VAR1:-0}-1"
--
Klaus Johannes Rusch
klausrusch(_at_)atmedia(_dot_)net
http://klausrusch.atmedia.net/
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail