diff options
author | mjarkk <mkopenga@gmail.com> | 2018-11-10 08:14:35 +0100 |
---|---|---|
committer | mjarkk <mkopenga@gmail.com> | 2018-11-10 08:14:35 +0100 |
commit | 1fd8cadd9efdc3e1a624f0d918042d69eef3853f (patch) | |
tree | cac4c02c66bca81156bcf974a65d43a4bcce7139 | |
parent | 17b4b4cb331bca6e4cc50d67e99cdac39f525694 (diff) |
Replaced regex with trim
-rw-r--r-- | pkg/commands/exec_live_default.go | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/pkg/commands/exec_live_default.go b/pkg/commands/exec_live_default.go index 88a80addb..0297cdcd1 100644 --- a/pkg/commands/exec_live_default.go +++ b/pkg/commands/exec_live_default.go @@ -6,7 +6,6 @@ import ( "bufio" "os" "os/exec" - "regexp" "strings" "sync" "unicode/utf8" @@ -56,16 +55,12 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s }() go func() { - // Regex to cleanup the command output - // sometimes the output words include unneeded spaces at eatch end of the string - re := regexp.MustCompile(`(^\s*)|(\s*$)`) - scanner := bufio.NewScanner(tty) scanner.Split(scanWordsWithNewLines) for scanner.Scan() { // canAsk prefrents calls to output when the program is already closed if canAsk() { - toOutput := re.ReplaceAllString(scanner.Text(), "") + toOutput := strings.Trim(scanner.Text(), " ") cmdOutput = append(cmdOutput, toOutput) toWrite := output(toOutput) if len(toWrite) > 0 { |