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 #1

Updated by Benoît PECCATTE over 9 years ago

  • Description updated (diff)
Actions #2

Updated by Benoît PECCATTE almost 9 years ago

  • Category set to System integration
  • Target version set to Ideas (not version specific)
Actions #3

Updated by François ARMAND almost 7 years ago

  • Severity set to Major - prevents use of part of Rudder | no simple workaround
  • User visibility set to Getting started - demo | first install | level 1 Techniques
  • Priority set to 0
Actions #4

Updated by Benoît PECCATTE almost 7 years ago

  • Effort required set to Medium
  • Priority changed from 0 to 44
Actions #5

Updated by Alexis Mousset almost 5 years ago

  • Subject changed from cfengine considers replacing a string with itself to not be convergent to agent considers replacing a string with itself to not be convergent
  • Priority changed from 44 to 0
Actions #6

Updated by François ARMAND about 2 years ago

  • Subject changed from agent considers replacing a string with itself to not be convergent to Document how to make replacing a string with itself convergent
  • Description updated (diff)
  • Category changed from System integration to Documentation

We won't correct that behavior in cfengine, but the workaround it noteworthy and should be document in related technique/generic method doc.

I'm updating the ticket to that.

Actions #7

Updated by François ARMAND about 2 years ago

  • Tracker changed from Bug to Enhancement
  • Severity deleted (Major - prevents use of part of Rudder | no simple workaround)
  • Priority deleted (0)
Actions

Also available in: Atom PDF