help-cfengine
[Top][All Lists]
Advanced

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

Re: Need 'UncommentAndSetValue' or some such


From: Tim Nelson
Subject: Re: Need 'UncommentAndSetValue' or some such
Date: Thu, 27 Oct 2005 12:36:06 +1000 (EST)

On Wed, 26 Oct 2005, David Scott Coburn wrote:

Brendan Strejcek wrote:

This is a commonly requested feature, check the archives for the
discussions.

This is what I find myself doing these days:

    editfiles:
        { /some/file
            DeleteLinesStarting "SomeVar" # Or Matching, whatever
            AppendIfNoSuchLine "SomeVar = SomeValue"
        }

This is perfectly convergent because cfagent edits the file in a buffer
and then compares to contents on disk. If there is no difference, the
actual file is not touched.

This is an improvement, but it would be nice if the edit did not move
the line you are editing to the end of the file.  Usually there is some
context of comments related to the variable you are setting.  The function
which edits and sets the variable should not change this.  This makes it
easier to look through the file if needed to find the line you are looking
for, to see what the settings are, and to reference the information in the
comments.

Btw, my solution (which is all done via templates) is probably something like:

        ResetSearch 0
        LocateLineMatching "whatever"
        ReplaceLineWith "otherwhatever"
        CatchAbort      # Catches abort from LocateLineMatching, so you
                        # can put other editfiles stuff after

        But I'm never sure, because I just write

        <? ReplaceLineMatchingWith("whatever", "otherwhatever"); ?>

        ...and my perl templating does the rest.

        :)

--
Kind Regards,
 
Tim Nelson
Server Administrator
 
P: 03 9934 0888
F: 03 9934 0899
E: tim.nelson@webalive.biz
W: www.webalive.biz
 
WebAlive Technologies
Level 1, Innovation Building
Digital Harbour
1010 La Trobe Street
Docklands Melbourne VIC 3008

This email (including all attachments) is intended solely for the named 
addressee. It is confidential and may contain legally privileged information. If
you receive it in error, please let us know by reply email, delete it from your 
system and destroy any copies. This email is also subject to copyright. No
part of it should be reproduced, adapted or transmitted without the written 
consent of the copyright owner.

Emails may be interfered with, may contain computer viruses or other defects 
and may not be successfully replicated on other systems. We give no
warranties in relation to these matters. If you have any doubts about the 
authenticity of an email purportedly sent by us, please contact us immediately.

reply via email to

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