procmail
[Top] [All Lists]

shell for ~/.forward

1998-05-03 12:19:05
Howard Schwartz asked,

S> Second, my default shell is c-shell. Therefore should I not use C Chell
S> syntax in my .forward file to forward mail to procmail for processing?
S> Most sample .forward lines appear to use bourne shell syntax.

Philip Guenther responded,

G> Actually, we recommend that you put
G>      SHELL = /bin/sh
G> at the top of your .procailrc and always use bourne shell syntax.  The
G> C-shell is just broken with regards to programming and scripting.

True, and that will take care of shell invocations in the rcfile, but Howard
was asking which shell's syntax to use in his .forward.

The answer is whichever shell is used to interpret pipes in .forward files
and the aliases file.  (I don't know whether that is the MTA's job or the
LDA's job; the former, I think, but don't rely on my guess.)  Usually that
will be whatever resides at /bin/sh (on one system I used to use, /bin/sh was
a link to bash, so pipes in .forward and the aliases file understood tildes).

When procmail starts reading your rcfile, it will look up your login shell
from /etc/passwd as the default setting for $SHELL; csh and derivatives are
not good for scripting, so if your login shell is csh, tcsh, or ntcsh, take
Philip's advice and set SHELL = /bin/sh (or an sh-compatible shell, such as
bash, ksh, pdksh, or zsh [listed alphabetically, not in order of preference])
at the top of your rcfile.  But procmail cannot select the shell used to read
your .forward, as it is read before procmail is invoked if you need to use
a .forward to call procmail.  That shell choice is hard-coded into the MTA (or
the LDA?) at compilation time.

If you need to be positive that a certain shell interprets your .forward,
pipe to that shell and use its -c option.  Possibilities range from

"|/bin/sh -c 'exec /path/to/procmail -Ytf-'"

to [on one long line]

"|/bin/sh -c 'IFS=\" \"&&p=/path/to/procmail&&test -x $p&&exec $p -Ytf-||exit 
75' #your_logname_here"

<Prev in Thread] Current Thread [Next in Thread>