From 8a79e547cc3d43bdc43a47a959f0e9a3b37b9d9d Mon Sep 17 00:00:00 2001 From: James Peach Date: Mon, 6 Sep 2021 07:46:08 +1000 Subject: [PATCH 1/2] Fix shell output log formatting. This fixes #982. Signed-off-by: James Peach --- modules/shell/command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/shell/command.go b/modules/shell/command.go index c23db4633..ffa503713 100644 --- a/modules/shell/command.go +++ b/modules/shell/command.go @@ -176,7 +176,7 @@ func readData(t testing.TestingT, log *logger.Logger, reader *bufio.Reader, writ break } - log.Logf(t, line) + log.Logf(t, "%s", line) if _, err := writer.WriteString(line); err != nil { return err } From 9b2f5ad2d4e878d810b26eeb13f0beceb602094a Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 7 Sep 2021 10:14:17 +1000 Subject: [PATCH 2/2] Add comment. Signed-off-by: James Peach --- modules/shell/command.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/shell/command.go b/modules/shell/command.go index ffa503713..9c20c8e0e 100644 --- a/modules/shell/command.go +++ b/modules/shell/command.go @@ -176,7 +176,14 @@ func readData(t testing.TestingT, log *logger.Logger, reader *bufio.Reader, writ break } + // logger.Logger has a Logf method, but not a Log method. + // We have to use the format string indirection to avoid + // interpreting any possible formatting characters in + // the line. + // + // See https://github.com/gruntwork-io/terratest/issues/982. log.Logf(t, "%s", line) + if _, err := writer.WriteString(line); err != nil { return err }