preserve left-side whitespace in output

This commit is contained in:
Matthew Hooker 2017-07-24 14:24:28 -07:00
parent b9d1fada25
commit 6d997d82e0
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
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.