procmail
[Top] [All Lists]

to meta or not to meta

1997-12-04 15:15:17
Jari Aalto asked,

| I'm lost here. How does the procmail actually call external programs?

That I do not know, but when it sees a character from $SHELLMETAS, it runs
        $SHELL $SHELLFLAGS "command -opts args" # usually, $SHELLFLAGS is "-c"
instead of
        command -opts args

That is because procmail's ability to invoke other programs does not include
filename globbing ("[", "*", "?"), backgrounding ("&"), piping ("|"), succes-
sion (";"), nor dependent succession ("&&", "||").  If it sees any of those
characters (before expanding variables), it hands the job over to a shell.

Sometimes those characters appear in arguments to a command without having
their shell metameaning and procmail really could invoke the command directly
without the shell.

You can see the distinction in a verbose logfile: if procmail runs the
command itself, it logs
        Executing "command,-opts,args"
with a comma between each two positional parameters, but if it calls a shell,
the original spacing from the rcfile is repeated unchanged in the logfile:
        Executing "command -opts args"

| I have only used fork for own C/Perl binaries, but how does
| procmail "sh" or "fork" an awk when the code "has" or "has not" shell metas,
| ie. Braces in this case.

Braces are not shell metacharacters for this, but brackets are.

| Why would we need to avoid "shell metas" so hard?

To save the overload of the extra layer of shell.  It may be extra work
once when you write your rcfile but it saves effort on each piece of arriving
email.