Skip to content

Commit d412df0

Browse files
morrison12Fizzadar
authored andcommitted
facts/files.Block: improve handling of special characters in marker strings
1 parent 56f8f77 commit d412df0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pyinfra/facts/files.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,13 @@ def command(self, path, marker=None, begin=None, end=None):
643643
QuoteString(f"{EXISTS}{path}"),
644644
QuoteString(f"{MISSING}{path}"),
645645
)
646-
# m_f_s_c inserts blanks in unfortunate places, e.g. after first slash
647-
cmd = make_formatted_string_command(
648-
f"awk \\'/{end}/{{{{f=0}}}} f; /{start}/{{{{f=1}}}}\\' {{0}} || {backstop}",
646+
647+
cmd = StringCommand(
648+
f"awk '/{end}/{{ f=0}} f; /{start}/{{ f=1}} ' ",
649649
QuoteString(path),
650+
" || ",
651+
backstop,
652+
_separator="",
650653
)
651654
return cmd
652655

0 commit comments

Comments
 (0)