procmail
[Top] [All Lists]

Re: duh - formail and variables for switches?

2002-04-05 13:50:07
Sean asked,

| I'm trying to make an option to formail a rule-invoked option (the
| LIST_OPTIONS is actually a line read in from a config file, containing
| multiple options which may pertain to a mailing list which I have a bounce
| manager running on):
|
|
| # running under Sean's sandbox config!
|
| # mimic stuff as if it'd been set from the options file
| BOUNCER=listowner-something(_at_)somewhere(_dot_)com
| FILTER_OPTIONS="listname BCCBOUNCE"
|
| :0
| * FILTER_OPTIONS ?? [ ]BCCBOUNCE\>
| {
|          BOUNCEOWNER=-I\ \"Bcc:\ $BOUNCER\"
| }
|
| # this actually would have some sed and cat stuff prefixed, but our only
| # focus here is to get formail working with the option
| :0
| | formail -I "Subject: [BOUNCE ADVISORY] blah blah" \
| -I "From: $BOUNCER" \
| -I "To: somebody(_at_)there(_dot_)com" $BOUNCEOWNER \
| -I "X-Loop: $BOUNCER" | $SENDMAIL -t -f $BOUNCER

| Suffice it to say that when BOUNCEOWNER is empty, no problem, and when the
| text of it (sans the escaping of the doublequotes) is in the formail
| invocation, it works.  The point here is to make the BCC an option.  Due to
| other scripting complexities, I don't want to have multiple formail
| invocations.

| I've tried:
|
| BOUNCEOWNER='-I "Bcc: $BOUNCER"'
| BOUNCEOWNER='-I "Bcc: hardcodedbounceaddr(_at_)domain(_dot_)tld"'
| BOUNCEOWNER="-I \"Bcc: $BOUNCER\""
| BOUNCEOWNER="-I "Bcc: hardcodedbounceaddr(_at_)domain(_dot_)tld\""
| BOUNCEOWNER=-I\ \"Bcc:\ $BOUNCER\"
|
| (also all those without the space between -I and the field)
|
| I get the expected result in the logfile from the assignment:
|
| procmail: Assigning "BOUNCEOWNER=-I "Bcc: $BOUNCER""
|
| or:
|
| procmail: Assigning "BOUNCEOWNER=-I "Bcc:
listowner-something(_at_)somewhere(_dot_)com""
| (as in the unquoted, escaped last variant above).
|
| etc.
|
| No dice - formail consistently emits a usage banner whenever BCCBOUNCE is
| non-empty (for the string I'm trying to use).  If instead, I set it to be a
| simple option, such as -rt, formail accepts that.

Since there are no characters from $SHELLMETAS in the command string, I don't
have to ask what your shell is.  Thus,

 :0
 * FILTER_OPTIONS ?? [ ]BCCBOUNCE\>
 {
          BOUNCEOWNER=Rumplestiltskin # any non-null string
 }

 :0
 | formail -I "Subject: [BOUNCE ADVISORY] blah blah" \
  -I "From: $BOUNCER" \
  -I "To: somebody(_at_)there(_dot_)com" ${BOUNCEOWNER:+-I "Bcc: $BOUNCER"} \
  -I "X-Loop: $BOUNCER" | $SENDMAIL -t -f $BOUNCER

Another possibility is

 -I "Bcc:${BOUNCEOWNER:+ $BOUNCER}"

which, if $BOUNCEOWNER is null or unset, will have the harmless effect of
removing any Bcc: lines from the input (I gather there wouldn't be any).

Another is to forget about -t:

 :0
 | formail -I "Subject: [BOUNCE ADVISORY] blah blah" \
  -I "From: $BOUNCER" \
  -I "To: somebody(_at_)there(_dot_)com" \
  -I "X-Loop: $BOUNCER" | \
  $SENDMAIL -f $BOUNCER somebody(_at_)there(_dot_)com ${BOUNCEOWNER:+$BOUNCER}



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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