Merge pull request #5167 from hashicorp/fix5147

preserve left-side whitespace in output
This commit is contained in:
Matthew Hooker 2017-08-28 14:22:34 -07:00 committed by GitHub
commit 68287566b8
1 changed files with 4 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import (
"os" "os"
"strings" "strings"
"sync" "sync"
"unicode"
"github.com/mitchellh/iochan" "github.com/mitchellh/iochan"
) )
@ -154,11 +155,11 @@ OutputLoop:
// Make sure we finish off stdout/stderr because we may have gotten // Make sure we finish off stdout/stderr because we may have gotten
// a message from the exit channel before finishing these first. // a message from the exit channel before finishing these first.
for output := range stdoutCh { for output := range stdoutCh {
ui.Message(strings.TrimSpace(output)) ui.Message(r.cleanOutputLine(output))
} }
for output := range stderrCh { for output := range stderrCh {
ui.Message(strings.TrimSpace(output)) ui.Message(r.cleanOutputLine(output))
} }
return nil return nil
@ -196,7 +197,7 @@ func (r *RemoteCmd) Wait() {
// UI output when we're reading from a remote command. // UI output when we're reading from a remote command.
func (r *RemoteCmd) cleanOutputLine(line string) string { func (r *RemoteCmd) cleanOutputLine(line string) string {
// Trim surrounding whitespace // Trim surrounding whitespace
line = strings.TrimSpace(line) line = strings.TrimRightFunc(line, unicode.IsSpace)
// Trim up to the first carriage return, since that text would be // Trim up to the first carriage return, since that text would be
// lost anyways. // lost anyways.