procmail
[Top] [All Lists]

Re: missing cat data

1999-09-30 14:26:42
Thanks to Era and Adam for explaining the sed code to Dave.  Adam wrote,
though,

| The '' is used
| around ^$/ to avoid risk that the shell will try to expand out $/,

Actually, no.  $/ is not a valid variable name, so it would be left alone
inside weak quotes.  I used strong quotes on the first -e argument because
I usually do around command line arguments that need quoting, in case there
is something that would get altered inside weak quotes.  In that particular
case, weak quotes would have worked equally well, as Era said.

| ... while the " is used around "$PMDIR/autoack" to ensure that the
| variable is expanded.

Right.  There I had to use weak quotes, so I did.

The sed script says simply this: everywhere except from the first line
through the first empty line (that is, everywhere except the head, which is
to say, in the body), go straight to the end of the script and print the
line by default (no -n option).  If we don't skip the second instruction
(that is, in the head), print the line by default and then add a copy of
$PMDIR/autoack.txt if the line from the input is empty.  To avoid inserting
a copy of the autoack file after every empty line in the message, we make
sure that sed skips around the second instruction during the body.

It could also have been done this way:

 :0c
 * conditions
 {
  :0fwh
  | formail -rt -I"Subject: whatever it was" ; cat $PMDIR/autoack.txt

  :0
  ! -oi -t
 }

or this way:

 :0c
 * conditions
 {
  :0fwh
  | formail -rt -I"Subject: whatever it was"

  :0fwb
  | cat $PMDIR/autoack.txt - # note trailing hyphen

  :0
  ! -oi -t
 }

but it seemed that the goal was to get the copy for the autoresponse off in
one pipeline without forking a clone procmail.

(Don't you just love Adam's domain name?)

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