Re: Re: Look-ahead regex, not matching?
Bob <[email protected]> Wed, 9 Jul 2025 09:41:41 -0700 (PDT)
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_367714_1995414442.1752079301434
Content-Type: multipart/alternative;
boundary="----=_Part_367715_104075430.1752079301434"
------=_Part_367715_104075430.1752079301434
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Thanks, Nick. FYI - I updated to "core" 3.24.2.
I tried the following scenarios after the update:
edit_line =3D> my_replace("\*mode:\s+(?!blan.*$).*",=20
edit_line =3D> my_replace("\*mode:\s+(?!blank.*).*",=20
edit_line =3D> my_replace("\*mode:\s+(?!blan.+).*", =20
edit_line =3D> my_replace("\*mode:\s+(?!blank$).*",=20
edit_line =3D> my_replace("\*mode:\s+(?!blank$).*$",
edit_line =3D> my_replace("\*mode:\s+(?!blank).*",
All of which gave the same error (but did perform the edit). On subsequent=
=20
runs of cf-agent, the file is no longer edited/updated. I suspect this is a=
=20
glitch of some sort.=20
On Wednesday, July 9, 2025 at 7:13:51=E2=80=AFAM UTC-7 [email protected]=
ech=20
wrote:
> Hey Bob,=20
>
> When I change it to this, it works:=20
>
> edit_line =3D> my_replace("\*mode:\s+(?!blank.*).*", "*mode: blank"),=20
>
> In my short test file, it works just fine. However, when I add it to my=
=20
> site.cf file:=20
>
> error: Promised replacement '*mode: blank' for pattern '^(\*=20
> mode:\s+(?!blank.*).*)\(' is not properly convergent while editing=20
> '/etc/X11/app- defaults/XScreenSaver-nogl' (pattern still matches the=20
> end-state replacement string '*mode: blank', consider use of a negative=
=20
> look ahead) error: Errors encountered when actuating replace_patterns=20
> promise '^(\*mode:\ s+(?!blank.*).*)\)'=20
>
> What could be the difference?=20
>
> I think it should be like this:=20
>
>
> edit_line =3D> my_replace("\*mode:\s+(?!blank$).*$",
>
> But, I think that this might be of use to you as well:=20
> https://gist.github.com/nickanderson/1ffd7936b66b4a7c1e703fbbdc49e0d1=20
>
--=20
You received this message because you are subscribed to the Google Groups "=
help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/help-cfengi=
ne/9d0eb4f6-0bc6-4cbb-94b1-9e4567457265n%40googlegroups.com.
------=_Part_367715_104075430.1752079301434
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div>Thanks, Nick. FYI - I updated to "core" 3.24.2.</div><div><br /></div>=
<div>I tried the following scenarios after the update:</div><div><br /></di=
v><div>=C2=A0 =C2=A0 =C2=A0 edit_line =C2=A0 =C2=A0 =3D> my_replace("\*m=
ode:\s+(?!blan.*$).*",=C2=A0<br />=C2=A0 =C2=A0 =C2=A0 edit_line =C2=A0 =C2=
=A0 =3D> my_replace("\*mode:\s+(?!blank.*).*",=C2=A0<br />=C2=A0 =C2=A0 =
=C2=A0 edit_line =C2=A0 =C2=A0 =3D> my_replace("\*mode:\s+(?!blan.+).*",=
=C2=A0=C2=A0<br />=C2=A0 =C2=A0 =C2=A0 edit_line =C2=A0 =C2=A0 =3D> my_r=
eplace("\*mode:\s+(?!blank$).*",=C2=A0<br />=C2=A0 =C2=A0 =C2=A0 edit_line =
=C2=A0 =C2=A0 =3D> my_replace("\*mode:\s+(?!blank$).*$",<br />=C2=A0 =C2=
=A0 =C2=A0 edit_line =C2=A0 =C2=A0 =3D> my_replace("\*mode:\s+(?!blank).=
*",<br /></div><div><br /></div><div>All of which gave the same error (but =
did perform the edit). On subsequent runs of cf-agent, the file is no longe=
r edited/updated. I suspect this is a glitch of some sort.=C2=A0</div><div>=
<br /></div><div><br /></div><div class=3D"gmail_quote"><div dir=3D"auto" c=
lass=3D"gmail_attr">On Wednesday, July 9, 2025 at 7:13:51=E2=80=AFAM UTC-7 =
[email protected] wrote:<br/></div><blockquote class=3D"gmail_quote" =
style=3D"margin: 0 0 0 0.8ex; border-left: 1px solid rgb(204, 204, 204); pa=
dding-left: 1ex;"><p>
Hey Bob,
</p>
<blockquote style=3D"border-left:2px solid gray;padding-left:4px"></blockqu=
ote><blockquote style=3D"border-left:2px solid gray;padding-left:4px">
<p>
When I change it to this, it works:
</p>
<p>
edit_line =3D> my_replace("\*mode:\s+(?!blank.*).*",
"*mode: blank"),
</p>
<p>
In my short test file, it works just fine. However, when I add it to my <a =
href=3D"http://site.cf" target=3D"_blank" rel=3D"nofollow" data-saferedirec=
turl=3D"https://www.google.com/url?hl=3Den&q=3Dhttp://site.cf&sourc=
e=3Dgmail&ust=3D1752159606241000&usg=3DAOvVaw2H-uxaCSM6yRpvwLyt9J0l=
">site.cf</a> file:
</p>
</blockquote><blockquote style=3D"border-left:2px solid gray;padding-left:4=
px"><p>
error: Promised replacement '<b>mode: blank' fo=
r pattern '^(\</b>
mode:\s+(?!blank.*).*)\(' is not properly convergent while editing '=
;/etc/X11/app-
defaults/XScreenSaver-nogl' (pattern still matches the end-state rep=
lacement string '*mode: blank', consider use of=
a negative look ahead)
error: Errors encountered when actuating replace_patterns promise =
9;^(\*mode:\
s+(?!blank.*).*)\)'
</p></blockquote><blockquote style=3D"border-left:2px solid gray;padding-le=
ft:4px">
<p>
What could be the difference?
</p>
</blockquote><blockquote style=3D"border-left:2px solid gray;padding-left:4=
px"></blockquote>
<p>
I think it should be like this:
</p>
<pre>
edit_line =3D> my_replace("\*mode:\s+(?!blank$).*$",
</pre>
<p>
But, I think that this might be of use to you as well: <a href=3D"https://g=
ist.github.com/nickanderson/1ffd7936b66b4a7c1e703fbbdc49e0d1" target=3D"_bl=
ank" rel=3D"nofollow" data-saferedirecturl=3D"https://www.google.com/url?hl=
=3Den&q=3Dhttps://gist.github.com/nickanderson/1ffd7936b66b4a7c1e703fbb=
dc49e0d1&source=3Dgmail&ust=3D1752159606241000&usg=3DAOvVaw3cDX=
30I_xTAefdwDswhUFU">https://gist.github.com/nickanderson/1ffd7936b66b4a7c1e=
703fbbdc49e0d1</a>
</p>
</blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;help-cfengine" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">help-=
[email protected]</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
help-cfengine/9d0eb4f6-0bc6-4cbb-94b1-9e4567457265n%40googlegroups.com?utm_=
medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/help-=
cfengine/9d0eb4f6-0bc6-4cbb-94b1-9e4567457265n%40googlegroups.com</a>.<br /=
>
------=_Part_367715_104075430.1752079301434--
------=_Part_367714_1995414442.1752079301434--