From a0cbc1a26ace658dd578cd9e699f3df3f1603b94 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Mon, 8 Apr 2024 13:29:22 -0400 Subject: [PATCH] cli: remove extraneous trailing newline from `nomad fmt` (#20318) When `nomad fmt` writes to stdout instead of overwriting a file, the command was using the `UI` output, which appends an extra newline. This results in extra trailing newlines when using `nomad fmt` as part of a pipeline or editor plugin. Update the command to write directly to stdout when in the stdout mode. Fixes: https://github.com/hashicorp/nomad/issues/20307 --- command/fmt.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command/fmt.go b/command/fmt.go index 289ec9834..09f75f266 100644 --- a/command/fmt.go +++ b/command/fmt.go @@ -280,7 +280,7 @@ func (f *FormatCommand) processFile(path string, r io.Reader) { } if f.writeStdout { - f.Ui.Output(string(out)) + formattedFile.WriteTo(os.Stdout) } }