procmail
[Top] [All Lists]

Re: setting shellmetas

2002-08-08 08:39:28
Hanspeter asked,

| What's the issue with SHELLMETAS?

When you have an action line that is a command (either a save-to-pipe or a
filter) or an

 * ? command

exit code condition, procmail will invoke the command with its options and
arguments if it can.  But there are certain things that may have to be done
first that shells normally do and procmail cannot.  Examples are,

1. filename globbing [the question mark at the beginning of an exit code
condition doesn't count]
2. backgrounding, as in  command -opts args &
3. exit status logic, as in  command1 && command2  or  command1 || command2
4. sequencing, as in  command1 ; command2
5. piping one command to another, as in  command1 | command2 [the pipe symbol
at the beginning of the action line doesn't count]
6. home directory substitution, as in  ~someotheruser  or even  ~
7. redirecting input or output

So when the command line includes certain characters, procmail invokes a shell
to run the command instead of trying to run the command itself.  The
SHELLMETAS variable is a string of those characters; I don't remember the
order and haven't access off-line to a man page [you can find the default
value in the procmailrc(5) manual], but if I recall correctly they're
ampersand, asterisk, semicolon, less-than sign, greater-than sign, question
mark, left bracket, pipe, and tilde.

Sometimes, though, those characters occur in the command string for other
reasons, like left brackets or asterisks in a regexp for sed or grep or expr,
or question marks or asterisks or angle brackets in a regexp for egrep, and
they're to be fed literally to the command rather than first interpreted by a
shell.  Usually then they're hard-quoted, so a shell won't mangle them, but
the extra cycles of invoking a shell to do something that procmail can manage
on its own are unnecessary.

By temporarily unsetting SHELLMETAS, we tell procmail that there's no
character in a command string that it can't handle on its own, and it
shouldn't even scan the command string to look for any.  By restoring the
value of $SHELLMETAS when we're done, procmail is then able to call a shell
farther along in the rcfile if it needs to.

| What happens if they have the original value?

Then the cycles are wasted for procmail to scan for the characters and
possibly to fork an extra shell process that wasn't needed.



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