help-cfengine
[Top][All Lists]
Advanced

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

Doc bug in the cfengine 2.0 reference?


From: Matt Armstrong
Subject: Doc bug in the cfengine 2.0 reference?
Date: Thu, 17 Jan 2002 13:52:45 -0700
User-agent: Gnus/5.090005 (Oort Gnus v0.05) Emacs/21.1 (i386-debian-linux-gnu)

Either cfengine's 2.0 InsertLine is broken, or the 2.0 reference is
incorrect.

The cfengine 2.0 reference manual recommends this technique when you
want to insert something in a file only once (within an editfiles):

    { file

      LocateLineMatching "^insert$"
      IncremenetPointer "1"
      BeginGroupIfNoMatch "# cfengine - 2/Jan/95"
        InsertLine "# cfengine - 2/Jan/95"
        InsertLine "whatever"
      EndGroup
    }

This is what happens with cfengine 2.0

    LocateLineMatching -- goes to line X
    IncrementPointer -- goes to line X+1
    BeginGroupIfNoMatch -- doesn't match
    InsertLine "# cfengine - 2/Jan/95" -- inserts text as line X+2
    InsertLine "whatever" -- inserts text as line X+3

So if I had a text file that was:

    insert
    after insert

It now looks like

    insert
    after insert
    # cfengine - 2/Jan/95
    whatever

Next time through

    LocateLineMatching -- goes to line X ("insert")
    IncrementPointer -- goes to line X+1 ("after insert")
    BeginGroupIfNoMatch -- doesn't match
    InsertLine "# cfengine - 2/Jan/95" -- inserts text as line X+2
    InsertLine "whatever" -- inserts text as line X+3

And you get:

    insert
    after insert
    # cfengine - 2/Jan/95
    whatever
    # cfengine - 2/Jan/95
    whatever

Unless this is a bug in 2.0's InsertLine, I think the fix to the docs
is:

    { file

      LocateLineMatching "^insert$"
      IncremenetPointer "1"
      BeginGroupIfNoMatch "# cfengine - 2/Jan/95"
          IncremenetPointer "-1"
          InsertLine "# cfengine - 2/Jan/95"
          InsertLine "whatever"
      EndGroup
    }

-- 
matt



reply via email to

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