summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormjarkk <mkopenga@gmail.com>2018-12-17 08:58:09 +0100
committermjarkk <mkopenga@gmail.com>2018-12-17 08:58:09 +0100
commitf5f726e9c46450fee60330c1c453d33d1566e106 (patch)
treece9344022f0632a1b6784f93c84955ac7f89a5d4
parentc56b303b2983e313261db6e89891058fa63739ac (diff)
A try to hide the password from the error output
-rw-r--r--pkg/commands/exec_live_default.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/commands/exec_live_default.go b/pkg/commands/exec_live_default.go
index 5ee5bdf75..37e27625a 100644
--- a/pkg/commands/exec_live_default.go
+++ b/pkg/commands/exec_live_default.go
@@ -36,6 +36,8 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
return err
}
+ lastWritten := ""
+
var waitForBufio sync.WaitGroup
waitForBufio.Add(1)
@@ -47,6 +49,8 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
cmdOutput = append(cmdOutput, toOutput)
toWrite := output(toOutput)
if len(toWrite) > 0 {
+ toWriteSplit := strings.Split(toWrite, " ")
+ lastWritten = toWriteSplit[len(toWriteSplit)-1]
// don't do len(cmdOutput)-1 because the next value is the username / password
cmdOutputOffset = len(cmdOutput)
_, _ = tty.WriteString(toWrite + "\n")
@@ -59,6 +63,11 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
tty.Close()
if err != nil {
waitForBufio.Wait()
+ for i, item := range cmdOutput {
+ if lastWritten == item && cmdOutputOffset < i {
+ cmdOutputOffset = i + 1
+ }
+ }
if cmdOutputOffset > len(cmdOutput)-1 {
cmdOutputOffset = len(cmdOutput) - 1
}