diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2021-01-17 19:19:06 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-17 19:19:06 -0500 |
| commit | 9eb3469a26a797e3a79788e6ed9d93fb598f4f8e (patch) | |
| tree | bacfe7d43c23acc6a8e851ed95eb1fd3ebfe0f5a | |
| parent | 9541e0bd52097c6efe3c7124c1a5cd1ca4d6ba0e (diff) | |
| parent | 92616afcbf594a3db08006279a5cc25e2209d011 (diff) | |
Merge pull request #1041 from hairyhenderson/only-newline-with-stdout
Only print newline to when outputting to os.Stdout
| -rw-r--r-- | internal/cmd/main.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/internal/cmd/main.go b/internal/cmd/main.go index 9217a725..5cbbc47a 100644 --- a/internal/cmd/main.go +++ b/internal/cmd/main.go @@ -95,11 +95,13 @@ func NewGomplateCmd() *cobra.Command { // print a newline to stderr for convenience if the output is going // to stdout, since otherwise the shell prompt may look wrong - // Note: once stdin/out/err are externalized we should only do this - // if stdout isn't ending with its own newline! - if len(cfg.OutputFiles) == 0 || (len(cfg.OutputFiles) == 1 && cfg.OutputFiles[0] == "-") && !cfg.ExecPipe { + // TODO: consider only doing this if stdout doesn't have a trailing + // newline already. + if len(cfg.OutputFiles) == 0 || (len(cfg.OutputFiles) == 1 && cfg.OutputFiles[0] == "-") && + !cfg.ExecPipe && cfg.Stdout == os.Stdout { fmt.Fprintf(cmd.ErrOrStderr(), "\n") } + log.Debug().Int("templatesRendered", gomplate.Metrics.TemplatesProcessed). Int("errors", gomplate.Metrics.Errors). Dur("duration", gomplate.Metrics.TotalRenderDuration). |
