procmail
[Top] [All Lists]

Re: Putting some text into the Subject

1997-06-15 14:16:00
On Sun, 15 Jun 97 15:22:02 -0400, "Timothy J. Luoma" 
<luomat(_at_)peak(_dot_)org>
wrote:
I tried this at the commandline:

echo 'Your message regarding \"bug again\" of Sat Jun 14 1997 12:27:25 -0400 
 
was read on Sat Jun 14 1997 19:02:08 +0200.' | sed -e N -e'2{' -e 'y/\n/ /'  
-e 's/  */ /g' -e 's/^[^"]*"//' -e 's/"[^"]*$/' -eq -e'}'

and I got this:

sed: strings for y command are different lengths

Yeah, your sed doesn't understand \n. On the command line, you can use
something like

 $ sed -e 'y/
/ /'

but this is not very convenient inside Procmail scripts. (If you are
using csh, you shouldn't expect this to work, either, but then you
should generally not really expect anything at all. If you like
surprises, stick with csh. :-)
  I usually end up putting the stuff with newlines in it in a variable
and interpolating that when I need it:

    NL="
"
    :0b
    | sed -eN -e'2{' \
        -e "y/$NL/ /" -e 's/  */ /g' -e 's/^[^"]*"//' -e 's/"[^"*$/' -eq -e'}'

The sed script expects the message to be wrapped over two lines. 

Also, I don't know about your echo, but mine doesn't need backslashes
inside single-quoted strings for anything else than quoting single
quotes (and even that it does badly ;^).

Top of head getting flatter still, (i.e., this is untested),

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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