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"
"strings"
"sync"
"unicode"
"github.com/mitchellh/iochan"
)
@ -154,11 +155,11 @@ OutputLoop:
// Make sure we finish off stdout/stderr because we may have gotten
// a message from the exit channel before finishing these first.
for output := range stdoutCh {
ui.Message(strings.TrimSpace(output))
ui.Message(r.cleanOutputLine(output))
}
for output := range stderrCh {
ui.Message(strings.TrimSpace(output))
ui.Message(r.cleanOutputLine(output))
}
return nil
@ -196,7 +197,7 @@ func (r *RemoteCmd) Wait() {
// UI output when we're reading from a remote command.
func (r *RemoteCmd) cleanOutputLine(line string) string {
// 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
// lost anyways.