help-cfengine
[Top][All Lists]
Advanced

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

best way to express an 'editfiles' idiom?


From: Daniel Pittman
Subject: best way to express an 'editfiles' idiom?
Date: Mon, 21 Jul 2003 13:07:11 +1000
User-agent: Gnus/5.090016 (Oort Gnus v0.16) XEmacs/21.5 (cassava)

When I manage configuration files with cfengine, I frequently find
myself wanting to express the following action with 'editfiles':

  Make every line matching "^Value" equal to "Value foo"

Basically, to find every line with a given key in the file, and then to
ensure that the value is what I want.

I don't like using 'ReplaceAll' for this because it seems silly to edit
the file and reload the daemon configuration every time cfengine runs.

The best way I have found to express this, so far, has been:

    CommentLinesMatching "^UsePrivilegeSeparation.*no"
    AppendIfNoLineMatching "^UsePrivilegeSeparation" "UsePrivilegeSeparation 
yes"

This works, but it's rather verbose, and kind of hides exactly what is
being done. Obviously the non-matching lines can be deleted instead of
commented out.


So, is there a better way of expressing my intent?

I don't mind if it's not 'editfiles' based, but I would rather avoid
having to copy the configuration files around by hand.

    Daniel

-- 
It is disconcerting to reflect on the number of students we have flunked in
chemistry for not knowing what we later found to be untrue.
        -- quoted by Robert L. Weber's, _Science With a Smile_, 1992




reply via email to

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