Lars Kellogg-Stedman asked,
| I have a simple that includes a multi-line sed command. The command
| arguments are enclosed in single quotes, which in sh, and in procmail
| variable assignments, will allow it to span multiple lines.
|
| The filter recipe looks like:
|
| :0fb
| | $SED '
| /^end[ ]*$/ i\
| ---\
| (File uudecoded into $FILESPEC)\
| ---
| /^begin/,/^end[ ]*$/ d
| ' | \
| $SED "s%\$FILESPEC%$FILEDIR/$FILENAME%g"
First, why are you doing it in with sed piped to sed instead of just insert-
ing $FILEDIR/$FILENAME on the first pass?
Second, the opening line is missing a closing backslash, so procmail thinks
that's the end of the action line.
Third, I've put multi-line sed scripts into procmailrcs this way: when
you're using an a\, c\, or i\ command, which must have trailing backslashes,
it's worked for me to use *two* trailing backslashes; however, I've always
needed variable interpretation, so I've done that only inside weak quotes,
not inside strong ones. For commands other than a\, c\, and i\, I've been
less brave and simply given each one to sed with its own -e. Try this:
:0fb
| $SED -e "/^end[ ]*$/ i\\
---\\
(File uudecoded into $FILEDIR/$FILENAME)\\
---" -e '/^begin/,/^end[ ]*$/ d'
Some versions of sed may need this syntax to finish the i\ insertion with a
blank command line, but this depends on sed, not on procmail:
:0fb
| $SED -e "/^end[ ]*$/ i\\
---\\
(File uudecoded into $FILEDIR/$FILENAME)\\
---\\
" -e '/^begin/,/^end[ ]*$/ d'
Come to think of it, isn't that the same as this?
:0fb
| $SED -e "/^begin/,/^end[ ]*$/ c\\
---\\
(File uudecoded into $FILEDIR/$FILENAME)\\
---\\
"
or, with a saner sed,
:0fb
| $SED -e "/^begin/,/^end[ ]*$/ c\\
---\\
(File uudecoded into $FILEDIR/$FILENAME)\\
---"