procmail
[Top] [All Lists]

Re: stripping the signature from an email

2016-06-01 10:22:32
"@lbutlr" <kremels(_at_)kreme(_dot_)com> writes:
I have the following:

:0
{ 
  MSGTEXT=`/usr/local/bin/formail -I ""`
  LOG="1 MSGTEXT=${MSGTEXT}${NL}"
  MSGTEXT=`echo $MSGTEXT | sed '/^-- $/,$d'`
  LOG="${NL}2 MSGTEXT=${MSGTEXT}${NL}"
...

Which results in:

1 MSGTEXT=
one two three four five
Six seven eight

-- 
It's Tchaikovsky's 'Another One Bites the Dust'," said Crowley, closing
his eyes as they went through Slough.

2 MSGTEXT=one two three four five Six seven eight -- It's Tchaikovsky's 
'Another One Bites the Dust'," said Crowley, closing his eyes as they went 
through Slough.

Shouldn't the sed strip the signature delimiter and the signature text?

I assume that the echo is condensing the MSGTEXT without passing the newlines?

When you write

  MSGTEXT=`echo $MSGTEXT | sed '/^-- $/,$d'`

first the shell needs to construct the "echo" command.  It does that by
substituting the contents of $MSGTEXT and then processing the whitespace
into word separations.  So of MSGTEXT is "a b\nd e", the generated
command is

    echo a b d e

"echo" sees 4 arguments, and outputs them with spaces between:

    a b d e

That line is sent to "sed", etc.

The usual way to defeat this is

  MSGTEXT=`echo "$MSGTEXT" | sed '/^-- $/,$d'`

but a better way is your second code:

  MSGTEXT=`/usr/local/bin/formail -I "" | sed '/^-- $/,$d'`

which avoids putting the original message into MSGTEXT.

Dale
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail

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