New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: greedy match may cause unwanted replacement #58960
Conversation
say we have below 2 existing blocks in file, and we specify "marker_begin_text_1" in playbook to do an update. But because of greedy match, the content of block 2 will also be overwritten. So this pull request is to resolve this issue. marker_begin_text_1 content1 end marker_begin_text_2 content2 end
The test
The test
|
@@ -282,6 +282,8 @@ def main(): | |||
n0 = i | |||
if line == marker1: | |||
n1 = i | |||
if (n0 != None): | |||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not change current behaviour, add an option that defaults to the current greedy=yes|no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not change current behaviour, add an option that defaults to the current
greedy=yes|no
@bcoca
That would be wonderful to have such an option. Thank you for your adoption.
closing as per above |
SUMMARY
say we have below 2 existing blocks in file, and we specify "marker_begin_text_1" in playbook to do an update.
But because of greedy match, the content of block 2 will also be overwritten.
So this pull request is to resolve this issue.
marker_begin_text_1
content1
end
marker_begin_text_2
content2
end
ISSUE TYPE
COMPONENT NAME
files/blockinfile.py
ADDITIONAL INFORMATION