Re: [Exim] Possible bug in ${sg}

Góra strony
Delete this message
Reply to this message
Autor: Tore Anderson
Data:  
Dla: exim-users
Temat: Re: [Exim] Possible bug in ${sg}
Tore Anderson wrote:

> > I've been trying to make sure no unescaped ';' finds its way into one of
> > my configuration variables. I tried to use the ${sg} operator to run
> > this regular expression on the string: s/\\*;/\\;/g
> >
> > This works as I'd like it to with regular perl:
> >
> >    $ echo 'foo;bar\;baz\\;zot\\\;biff\\\\;bing' | perl -pe 's/\\*;/\\;/g'
> >    foo\;bar\;baz\;zot\;biff\;bing

> >
> > ..but not with exim (tested with both 3.25 and 4.11):
> >
> >    $ exim -be '${sg{foo;bar\;baz\\;zot\\\;biff\\\\;bing}{\\*;}{\\;}}'
> >    foo;bar;baz\;zot\;biff\\;bing


Nico Erfurth <masta@???> writes:

> use either this:
> exim -be '${sg{foo;bar\;baz\\;zot\\\;biff\\\\;bing}{\N\\*;\N}{\N\\;\N}}'
>
> or this
> exim -be '${sg{foo;bar\;baz\\;zot\\\;biff\\\\;bing}{\\\\*;}{\\\\\\;}}'
>
> The problem is, that first exim unescapes the \\ to \ then then pcre
> will do so too, your string would result in


Aha. I wonder why this behaviour isn't documented.

> exim -be '${sg{foo;bar\;baz\\;zot\\\;biff\\\\;bing}{*;}{;}}'
>
> you see?


I don't think that would be the result, if it did, the expansion should
have failed (* with no preceding character is clearly bogus), instead of
giving me the weird result it did. But I do see your point.

> If you enclose a string in \N exim will just pass it as it is.


That I didn't know, but it seems it is exactly the trick I'm looking for.
Thank you very much!

--
Tore Anderson