procmail
[Top] [All Lists]

Re: How to avoid s/\n/ /g when unfolding a header

2004-12-13 07:17:31
On Mon, Dec 13, 2004 at 12:59:03PM +0100, Robert Allerstorfer wrote:
OK, I think it is not possible to remove leading whitespace from each
line of a multiline string with pure procmail code. Therefore, I will

Well, it's possible, but you'd need a recursive rcfile.

  multiline_subj = `formail -zx Subject`
  INCLUDERC = do_me.inc

Inside "do_me.inc":

  :0
  * $ multiline_subj ?? $buildmeasubject$NL.*\/[^$WS]+
  {
     buildmeasubject = $buildmeasubject$MATCH
     SWITCHRC = $_
  }

  SWITCHRC  # this is our exit at the end


This is all completely untested, of course.

-----------
  
most likely use sed, like this:

av_SUBJECT = `formail -zx subject | sed -e 's/^[       ]*//'`

(having a SPACE and TAB within the []). A subject like

Subject: =?utf-8?q?First-line-followed-by-one-space?=
 Second-line

will result to

Assigning "av_SUBJECT2==?utf-8?q?First-line-followed-by-one-space?=
Second-line"

The next step is to delete all \n. Can this also done with sed?

Yes, 

   sed "s/$NL//g"

should work.  You can also include it in your class with whitespace.
However, I'd probably do the whole thing in tr (if I didn't use the
recursive INCLUDERC):

  av_SUBJECT = `formail -zx Subject | tr -d "[$WS$NL]"

-- 
dman

____________________________________________________________
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