Here are some of the new features of mpick(1):
mpick can now also act as interpreter to for mpick script files
instead of only allowing to supply expression through arguments.
Another new feature is redirecting mail paths matching expressions
to files or processes, similar to redirects work in awk.
The following example script moves matching mails into another maildir
by piping their path into mrefile(1).
By using mrefiles -v flag and using `? skip : print` the output
of this mpick script will be either the updated path of matching mails
or the original path of mails that did not match the expressions.
This would also work with other tools like mflag(1).
#!/usr/bin/mpick
("list-id".addr ~~ "*.
project1.com" |"mrefile -v ~/mail/project1" ||
"list-id".addr ~~ "*.
project2.com" |"mrefile -v ~/mail/project2")
? skip : print
Another new feature is assigning expressions to variables,
to make it a bit easier to maintain large filter scripts.
#!/usr/bin/mpick
let project1 = "list-id".addr == "
project1.com" |"mrefile -v ~/mail/project1"
let project2 = "list-id".addr == "
project2.com" |"mrefile -v ~/mail/project2"
in (project1 || project2) ? skip : print
Another example (with a second expression for project1) would be:
#!/usr/bin/mpick
let project1 =
"list-id".addr == "
project1.com" ||
"to".addr == "
m...@project1.com"
let project2 = "list-id".addr == "
project2.com"
let move =
project1 |"mrefile -v ~/mail/project1" ||
project2 |"mrefile -v ~/mail/project2"
in
move ? skip : print
The pipe (|"prog") can be replaced with >"newfile" or >>"append"
to write or append matching mails to files.
Cheers,
Duncan