littlecheck: Update to shell-quote replacements

Commit bb07435e3e4cbd34fcb667ec927353d176a0b2e8
This commit is contained in:
Fabian Boehm 2024-12-29 18:13:20 +01:00
parent cb3d004a5a
commit 17d57b70d0

View file

@ -367,7 +367,10 @@ def perform_substitution(input_str, subs):
text = m.group(1)
for key, replacement in subs_ordered:
if text.startswith(key):
return replacement + text[len(key) :]
# shell-quote the replacement, so it's usable in #RUN lines.
# We could loosen this and only do it for #RUN/#REQUIRES,
# but so far we don't need it anywhere.
return shlex.quote(replacement + text[len(key) :])
# No substitution found, so we default to running it as-is,
# which will end up running it via $PATH.
return text
@ -475,7 +478,7 @@ class TestRun(object):
"""Decode a string and split it by newlines only,
retaining the newlines.
"""
return [s + "\n" for s in s.decode("utf-8").split("\n")]
return [s + "\n" for s in s.decode("utf-8", errors="backslashreplace").split("\n")]
if self.config.verbose:
print(self.subbed_command)