procmail
[Top] [All Lists]

Re: escaping special characters (in general)

1995-10-31 01:34:37
From: dattier(_at_)wwa(_dot_)com (David W. Tamkin)
Date: Mon  Oct 30, 10:14am

Robert Brown wrote again:

| But, if "the subject" contains any regular expression chars (e.g., "*", 
"(",
| "?", etc.), then I'm screwed.

Right.  That's exactly what we're answering here.

   THE_SUBJECT="string including some characters that are magic in regexps"

    :0hf
    * $ ^Subject: (re: *)? *$\THE_SUBJECT
    | formail -I "Priority: A"

I hadn't tried this.  I'll give this a try.

| Do you see my problem?

I guess not, because this is the second time you've stated it, and both times
it looks like exactly what we're answering.  Maybe I see the problem but you
don't understand the answer.  Copy it carefully and give it a try, please,
with a logfile and verbose logging so that we can find out what happened if
it doesn't work.  Remember that "$\" requires at least procmail 3.11pre0.

Right, that's the version I'm using.

Moreover, I don't follow why you have to extract the subject with formail -x
or even with the MATCH operator.  Perhaps if you explained more of what
you're trying to do it would make more sense to us.

Basically, I have a sendmail that's this:

#!/bin/csh -f
cat > /tmp/resendmail.tmp
# this next line actually does the sending of the mail
procmail -p $0.proc < /tmp/resendmail.tmp
# now, give priority to subjects sent
set subject="`formail -x Subject < /tmp/resendmail.tmp | sed -e 's,\<Re: *,,g' 
-e 's,^ *,,'`"
grep "$subject" priority.proc > /dev/null
if ($status != 0) then
        echo ":Ef" >> priority.proc
        echo '*^subject: (re:)? *$\'"$subject" >> priority.proc
        echo '| formail -I "Priority: A"' >> priority.proc
endif

I guess what you're telling me is that it should say this instead:

#!/bin/csh -f
cat > /tmp/resendmail.tmp
# this next line actually does the sending of the mail
procmail -p $0.proc < /tmp/resendmail.tmp
# now, give priority to subjects sent
set subject="`formail -x Subject < /tmp/resendmail.tmp | sed -e 's,\<Re: *,,g' 
-e 's,^ *,,'`"
grep "$subject" priority.proc > /dev/null
if ($status != 0) then
        echo 'THE_SUBJECT="'"$subject"'"' >> priority.proc
        echo ":Ef" >> priority.proc
        echo '*$^subject: (re:)? *$\$THE_SUBJECT' >> priority.proc
        echo '| formail -I "Priority: A"' >> priority.proc
endif

Is this right?