procmail
[Top] [All Lists]

TRAP oddity

1996-07-25 13:15:04
Strange thing I noticed with procmail 3.11pre4 under FreeBSD:

I had TRAP defined in my .procmailrc there like so:

TRAP='
echo "some variables
more variables
" >> $LOGFILE'

and it was working fine.  I noticed that ">> $LOGFILE" was in there, and it
is superfluous in 3.11pre4, so I took it out:

TRAP='
echo "some variables
more variables
"'

That made the TRAP act like this:

TRAP="cat ."

and it would append a copy of the directory header of $MAILDIR to the logfile
instead of logging the data it was supposed to echo.  I realized that there
were now no characters from $SHELLMETAS in the TRAP commands, so I thought
something was funny with /bin/echo (now that it was using /bin/echo instead
of calling a shell, which would use its built-in echo), and I added one (note
the semicolon):

TRAP='
echo "some variables
more variables
";'

And that cured it, but there was the overhead of running a shell.  I tried
everything to get /bin/echo to bomb interactively, and I couldn't.  Then
something occurred to me: that initial open space.  This form:

TRAP='echo "some variables
more variables
"'

worked beautifully.  I guess the shell had been able to forgive that open
space at the beginning but procmail hadn't known what to do with it.
(A verbose logfile said

 Executing ""

never 

 Executing "cat ."

but still that should have tipped me off sooner.)  This did the trick too,
and it's what I stuck with so that the echo command and the lines to echo
could be flush against the left margin in my .procmailrc:

TRAP='\
echo "\
some variables
more variables
"'

<Prev in Thread] Current Thread [Next in Thread>
  • TRAP oddity, David W. Tamkin <=