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: Mark . Burgess
Subject: Re: How to use regex in editfiles?
Date: Wed, 1 Sep 2004 04:26:54 +0200 (MEST)


On 31 Aug, Wil Cooley 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...

This is documented, though nothing is ever documented clearly enough.

Regular expression implementations do not specify how they are to be used.
The point here is that the match should allow an unambiguous match for
convergence checking.

Frank is right that, for historical reasons, the available functions, the names
and the behaviours are a bit inconsistent. Unfortunately, once done it is
hard to change to a better idea without breaking something for someone.
One day it would be nice to redesign the editfiles functions.

There are certainly no "safety issues" with regular expressions. The usage
is designed to make their application as safe as possible, assuming that
you always check that they match what you think they do. Regular expressions are
supposed to be standard things, but they are very very far from being standard.
Some discusssion was given to using the perl regex library a while ago, which
is tempting, but then everything is broken again for every cfengine user
around the world :(

M

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272            Email:  Mark.Burgess@iu.hio.no
Fax : +47 22453205            WWW  :  http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





reply via email to

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