Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-1312

maintain_key_values is not convergent if replacement value has the same length as the old one; set_line_based reccommended

    XMLWordPrintable

    Details

    • Platform:
      Any

      Description

      A test file (/tmp/test):

      @foo = bar@

      promise.cf:

      <pre>
      body common control
      {
      bundlesequence =>

      { "example" }

      ;
      inputs =>

      { "$(sys.workdir)/inputs/libraries/cfengine_stdlib.cf" }

      ;
      }

      bundle agent example
      {
      vars:
      "v[foo]" string => "abc";

      files:

      "/tmp/test"
      edit_line => maintain_key_values("example.v","=");
      }
      </pre>

      output:
      <pre>
      $ cf-agent -KI
      2014-04-02T15:35:44+0200 error: /example/files/'/tmp/test'/maintain_key_values/replace_patterns/'($(keypat[$(index)]))(?!$(ve[$(index)])$).': Promised replacement 'foo = abc' on line 'foo = bar' for pattern '(\s*foo\s=\s*)(?!abc$).*' is not convergent while editing '/tmp/test'
      2014-04-02T15:35:44+0200 error: Because the regular expression '^(\s*foo\s*=\s*)(?!abc$).*' still matches the replacement string 'foo = abc'
      2014-04-02T15:35:44+0200 error: Promise belongs to bundle 'maintain_key_values' in file '/home/fabien/.cfagent/inputs/libraries/cfengine_stdlib.cf' near line 565
      2014-04-02T15:35:44+0200 error: Comment is 'Replace definition of foo'
      </pre>

      If the length of the value is different or if there is no space between the separator and the value, it works as expected. I don't know how to correct this bug.

      Regards,
      Fabien Grumelard

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10025 Volker Hilsheimer (Inactive)
                Reporter:
                fabix Fabien Grumelard (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel