> I believe it's because the line you are matching (HOSTNAME=node1) is 
> present, and the regexp matching the search line is not anchored to the 
> end of the line
> Using this regexp solved the issue :
> "^(?!$(line)$)$(pattern)$"
> 
> (note the extra $ after line)

Good catch, and thanks for the fix, Nicolas. This is indeed the problem:

- The new line matches the beginning of the old one, so the negative-lookahead 
(as it was written) does not match, hence the replacement never takes place.
- After this, the insert_lines promise inserts the new line, hence the 
duplication.

> I think the cfengine_stdlib should be corrected to avoid this bug.

I just committed the fix.

Thanks,
--Diego

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to