From 17d57b70d00faf636c47413ef646371cc2dae75d Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sun, 29 Dec 2024 18:13:20 +0100 Subject: [PATCH] littlecheck: Update to shell-quote replacements Commit bb07435e3e4cbd34fcb667ec927353d176a0b2e8 --- tests/littlecheck.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/littlecheck.py b/tests/littlecheck.py index d07c134f9..e3d843826 100755 --- a/tests/littlecheck.py +++ b/tests/littlecheck.py @@ -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)