help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use regex in editfiles?


From: Frank Smith
Subject: Re: How to use regex in editfiles?
Date: Tue, 31 Aug 2004 16:52:26 -0500

--On Tuesday, August 31, 2004 15:56:49 -0500 Wil Cooley <wcooley@nakedape.cc> 
wrote:
>On Sun, 2004-08-29 at 00:47 -0500, Frank Smith wrote:
>> Try this instead:
>> 
>> AppendIfNoLineMatching "cfengine[[:blank:]]5308/tcp.*"
>> 
>> which should also match lines with trailing spaces and/or comments.
>
>What I don't understand is why the .* are necessary--why does the regex
>have to match the whole line instead of a substring?  They aren't for
>other regex implementations.  I guess I could see a safety issue with
>it...
>
>Wil

The regex has to match the entire line because that is what it says it
does: append if no line matching.
I do think that cfengine is somewhat inconsistent in the implementation;
some of the editfiles functions have a 'contains' variant that does a
substring match, some only match the full line, and some have a 'starting
with' substring match.  For consistency I think that either they should
all just do line matching (using rexexp to enable substring matches), or
all have a *LineContaining variant.

Frank




reply via email to

[Prev in Thread] Current Thread [Next in Thread]