procmail
[Top] [All Lists]

Using sed

2001-04-21 15:32:14
I'm having little success using sed in assignments to environment
variables.

Doing something like this does work:

    SUBJECT=`formail -zxSubject: | sed "s/mail]/mail] /g"`

but this doesn't:

    TAG=`echo -n $SUBJECT|sed -e "s/\[([A-Za-z0-9\-_ ]*)\]/\1/g"`

I've tried the failing echo and sed combination in an interactive shell
and it works. (That is it captures any alphanumerics between brackets.)
However when I try the above procmailrc line it fails.

Here's an extract from the log when the receipe is applied to a message
from the fetchmail friends list. I've successfully capture the Subject:
line in the variable $SUBJECT.

procmail: Assigning "SUBJECT=Re: [fetchmail]Problem with "warnings" ? "
procmail: Executing "echo -n $SUBJECT|sed -e "s/\[([A-Za-z0-9\-_ ]*)\]/\1/g""
procmail: Assigning "TAG=Re: [fetchmail]Problem with "warnings" a h"

Note thast the sed neither returns just the tag (fetchmail) nor returns an
uncorrupted string. However, the interactive shell does return the right
and uncorrupted thing.

How can I fix it so that sed does return the right thing?

Just for completeness I'm using sed v3.02 and procmail v3.14 both stock
binaries from the RedHat 6.2 distribution. For further completeness I've
tried omitting the -n from echo and the -e from sed in all combinations.

Regards, Trevor

British Sign Language is not inarticulate handwaving; it's a living language.
Support the campaign for formal recognition by the British government now!

-- 

<>< Re: deemed!

_______________________________________________
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>