procmail
[Top] [All Lists]

Re: sed syntex in procmailrc question

2011-10-14 11:45:34
On Fri, Oct 14, 2011 at 5:46 AM, Harry Putnam <reader(_at_)newsguy(_dot_)com> 
wrote:
Zhiliang <hu(_at_)animalgenome(_dot_)org> writes:

I have a recipe wish 'sed' in one of my Smartlist rc, like:

   sed 's/SUBJET/'"$SUBJ"/g

which works fine.  I forgot where did I copied it from but have been
puzzled by its syntex with respect to the use of the single quotes
"'".

I'm certainly not any kind of expert on sed but I think what you may
be seeing is really a shell expansion thing.

To expand just a little on Harry's correct explanation:

In the literal example you included, the single quotes around
's/SUBJET/' are unnecessary.  You only need quotes to protect spaces,
dollar signs, and globbing characters like *?[].

However, my guess is that your real sed expression, which you have not
shown us, doesn't have the string SUBJET but instead has a complex
string that might contain some of those special characters that need
quoting.

In that case for clarity I might have written such an expression as

sed -e s/'The Real String Goes Here'/"$SUBJ"/g

rather than butting the two sets of quotes up against each other.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail

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