Project

General

Profile

Actions

Enhancement #5983

open

Document how to make replacing a string with itself convergent

Added by Benoît PECCATTE over 9 years ago. Updated about 2 years ago.

Status:
New
Priority:
N/A
Assignee:
-
Category:
Documentation
UX impact:
Suggestion strength:
User visibility:
Getting started - demo | first install | level 1 Techniques
Effort required:
Medium
Name check:
Fix check:
Regression:

Description

cf-agent gives an error with the following code :

bundle edit_line edit_one_line
{
        replace_patterns:
                "^test.*" replace_with => value("test me");
}

Withs this kind of error

2014-12-11T14:56:50+0100    error: /default/test4/files/'/tmp/test'/default/edit_one_line/replace_patterns/'^test.:'[0]: Promised replacement 'test' on line 'test ij' for pattern '^test.*' is not convergent while editing '/tmp/test'
2014-12-11T14:56:50+0100    error: /default/test4/files/'/tmp/test'/default/edit_one_line/replace_patterns/'^test.:'[0]: Because the regular expression '^test.*' still matches the replacement string 'test me'

It says that its not convergent since you replace a line with itself.
Nobody can understand that, and the user is understandably confused.

cfengine should be modified to make a regex that do not modify a line BE convergent.

== Workaround

For people wanting to work around this, you must prepend a zero width negative forward lookahead in your regex everywhere you have a quantifier that could match the final thing.
In this test case it would look like "^test(?! me).*"

Actions

Also available in: Atom PDF