help-cfengine
[Top][All Lists]
Advanced

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

Spurious non-convergent replace warning


From: Chip Seraphine
Subject: Spurious non-convergent replace warning
Date: Fri, 26 Sep 2003 18:07:14 -0500
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.2.1) Gecko/20030721



The following editfiles line:

                ReplaceAll "$(tab)+" With "$(spc)"

...invariably produces this:


cfengine:cuffs: WARNING: Non-convergent edit operation ReplaceAll [ ] With [ ]
        cfengine:cuffs: Line begins [127.0.0.1  localhost       ]
cfengine:cuffs: Replacement matches search string and will thus replace every time - edit was not done
        cfengine:cuffs: Error editing file /var/tmp/hosts


Obviously, replacing one or more tabs with a single space is not really non-convergent. The code in question (from item-ext.c, v 2.0.6, ~line 1350)

   if (regexec(&rx,VBUFF,1,&matchcheck,0) == 0)
      {
snprintf(OUTPUT,bufsize*2,"WARNING: Non-convergent edit operation ReplaceAll [%s] With [%s]",replace,search);
      CfLog(cferror,OUTPUT,"");
      snprintf(OUTPUT,bufsize*2,"Line begins [%.40s]",ip->name);
      CfLog(cferror,OUTPUT,"");
CfLog(cferror,"Replacement matches search string and will thus replace every time - edit was not done","");
      return false;
      }

...seems reasonable to the (near-)layman, but I get the same behavior on both Linux and Sun so I doubt it is a regexec bug.

How have others been handling this?

On a semi-aside, the reason this is coming up is because I am trying to ensure that a set of hosts exists in my /etc/hosts. It seems the most efficient way to do this is to loop thru the file and use ReplaceLinesMatchingField; however, since only a single char can be used in SplitOn, I have to normalize the delimiters first as done above. Anybody know of a patch or plans to allow for a regex or at least multiple characters to be used as SplitOn delimiters?





reply via email to

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