Re: Look-ahead regex, not matching?
Bob <[email protected]> Wed, 9 Jul 2025 07:00:59 -0700 (PDT)
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_721600_815465842.1752069659224
Content-Type: multipart/alternative;
boundary="----=_Part_721601_1891676654.1752069659224"
------=_Part_721601_1891676654.1752069659224
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
When I change it to this, it works:
edit_line =3D> my_replace("\*mode:\s+(?!blank.*).*",
"*mode: blank"),
In my short test file, it works just fine. However, when I add it to my=20
site.cf file:
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 end-state=20
replacement string '*mode: blank', consider use of a=20
negative look ahead)
error: Errors encountered when actuating replace_patterns promise=20
'^(\*mode:\
s+(?!blank.*).*)$'
What could be the difference?
On Tuesday, July 8, 2025 at 5:54:48=E2=80=AFPM UTC-7 [email protected] wrote:
> Hi Bob,
>
> Try edit_line =3D> my_replace("\*mode:\s+(?!blank$)"
>
> On Tuesday, July 8, 2025 at 5:50:31=E2=80=AFPM UTC-5 Bob wrote:
>
>> I am trying to change the default screensaver. The line of interest is a=
s=20
>> follows:
>>
>> *mode: random
>>
>> Note: there are 3 tab characters between the colon and the word "random"=
.
>>
>> Code:
>>
>> body file control
>> {
>> inputs =3D> { "/var/cfengine/share/CoreBase/masterfiles/lib/files.cf=
"=20
>> };
>> }
>>
>> body common control
>> {
>> bundlesequence =3D> { "example" };
>> }
>>
>> bundle agent example
>> {
>> files:
>> linux::
>> "/etc/X11/app-defaults/XScreenSaver-nogl"
>> comment =3D> "Set screensaver mode to blank",
>> edit_line =3D> my_replace("\*mode:\s+(?!blank)",
>> "*mode: blank"),
>> edit_defaults =3D> std_defs;
>>
>> }
>> bundle edit_line my_replace(regex,text)
>> {
>> replace_patterns:
>>
>> "^($(regex))$"
>>
>> replace_with =3D> value("$(text)"),
>> comment =3D> "Search and replace string";
>> }
>>
>> As best as I can tell, I am not matching the line. Any suggestions?
>>
>> Using CFEngine community 3.24.1.
>>
>> Thank you.
>>
>>
--=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/611ec560-cb4f-4745-b8d7-f26b4afe237fn%40googlegroups.com.
------=_Part_721601_1891676654.1752069659224
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div>When I change it to this, it works:</div><div><span style=3D"font-fami=
ly: Courier New;"><br /></span></div><div><span style=3D"font-family: Couri=
er New;">=C2=A0 =C2=A0 =C2=A0 =C2=A0 edit_line =C2=A0 =C2=A0 =3D> my_rep=
lace("\*mode:\s+(?!blank.*).*",<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 "*mode: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 blank"),</span><br /></div><div><br /></div><div>In my sh=
ort test file, it works just fine. However, when I add it to my site.cf fil=
e:</div><div><br /></div><div><span style=3D"font-family: Courier New;">=C2=
=A0 =C2=A0error: Promised replacement '*mode: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0blank' for pattern '^(\*<br />mode:\s+(?!=
blank.*).*)$' is not properly convergent while editing '/etc/X11/app-<br />=
defaults/XScreenSaver-nogl' (pattern still matches the end-state replacemen=
t string '*mode: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 blank', consider use of a negative look ahead)<br />=C2=A0 =
=C2=A0error: Errors encountered when actuating replace_patterns promise '^(=
\*mode:\<br />s+(?!blank.*).*)$'</span><br /></div><div><br /></div><div>Wh=
at could be the difference?</div><br /><div class=3D"gmail_quote"><div dir=
=3D"auto" class=3D"gmail_attr">On Tuesday, July 8, 2025 at 5:54:48=E2=80=AF=
PM 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); p=
adding-left: 1ex;"><div>Hi Bob,</div><div><br></div><div>Try=C2=A0<span sty=
le=3D"font-family:Courier New">=C2=A0 =C2=A0 =C2=A0 edit_line =C2=A0 =C2=A0=
=3D> my_replace("\*mode:\s+(?!blank$)"</span></div><br><div c=
lass=3D"gmail_quote"><div dir=3D"auto" class=3D"gmail_attr">On Tuesday, Jul=
y 8, 2025 at 5:50:31=E2=80=AFPM UTC-5 Bob wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 0.8ex;border-left:1px solid rgb(204,=
204,204);padding-left:1ex"><div>I am trying to change the default screensav=
er. The line of interest is as follows:</div><div><br></div><div><span styl=
e=3D"font-family:Courier New">*mode: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0random</span><br></div><div><br></div><div>Note: th=
ere are 3 tab characters between the colon and the word "random".=
</div><div><br></div><div>Code:</div><div><br></div><div><span style=3D"fon=
t-family:Courier New">body file control<br>{<br>=C2=A0 =C2=A0 inputs =3D>=
; { "/var/cfengine/share/CoreBase/masterfiles/lib/<a href=3D"http://fi=
les.cf" rel=3D"nofollow" target=3D"_blank" data-saferedirecturl=3D"https://=
www.google.com/url?hl=3Den&q=3Dhttp://files.cf&source=3Dgmail&u=
st=3D1752152113076000&usg=3DAOvVaw0auURe_BYycgB3zwvJ4-gw">files.cf</a>&=
quot; };<br>}<br><br>body common control<br>{<br>=C2=A0 =C2=A0 =C2=A0 bundl=
esequence =3D> { "example" };<br>}<br><br>bundle agent example=
<br>{<br>=C2=A0 files:<br>=C2=A0 =C2=A0 linux::<br>=C2=A0 =C2=A0 =C2=A0 &qu=
ot;/etc/X11/app-defaults/XScreenSaver-nogl"<br>=C2=A0 =C2=A0 =C2=A0 co=
mment =C2=A0 =C2=A0 =C2=A0 =3D> "Set screensaver mode to blank"=
;,<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 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 "*mode: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 blank"),<br>=C2=A0 =C2=A0 =C2=A0 edit_defaults =
=3D> std_defs;<br><br>}<br>bundle edit_line my_replace(regex,text)<br>{<=
br>replace_patterns:<br><br>=C2=A0"^($(regex))$"<br><br>=C2=A0 =
=C2=A0 =C2=A0replace_with =3D> value("$(text)"),<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 comment =3D> "Search and replace string&qu=
ot;;<br>}</span><br></div><div><br></div><div>As best as I can tell, I am n=
ot matching the line. Any suggestions?</div><div><br></div><div>Using CFEng=
ine community=C2=A03.24.1.</div><div><br></div><div>Thank you.</div><div><b=
r></div></blockquote></div></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/611ec560-cb4f-4745-b8d7-f26b4afe237fn%40googlegroups.com?utm_=
medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/help-=
cfengine/611ec560-cb4f-4745-b8d7-f26b4afe237fn%40googlegroups.com</a>.<br /=
>
------=_Part_721601_1891676654.1752069659224--
------=_Part_721600_815465842.1752069659224--