From 9c00af5e50006ff38de5d9ec8fe1a44a8f1eeeae Mon Sep 17 00:00:00 2001 From: sqshq Date: Fri, 23 Aug 2019 22:33:34 -0400 Subject: [PATCH] cleanup escape codes for regular and interactive shell sampling --- data/int_basic.go | 3 ++- data/item.go | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/data/int_basic.go b/data/int_basic.go index 39fe594..fabb669 100644 --- a/data/int_basic.go +++ b/data/int_basic.go @@ -4,6 +4,7 @@ import ( "bufio" "errors" "fmt" + "github.com/lunixbochs/vtclean" "io" "os/exec" "strings" @@ -118,7 +119,7 @@ func (s *BasicInteractiveShell) execute() (string, error) { if errorText.Len() > 0 { return "", errors.New(errorText.String()) } - return s.item.transform(resultText.String()) + return s.item.transform(vtclean.Clean(resultText.String(), false)) } } } diff --git a/data/item.go b/data/item.go index 38a8898..47afa74 100644 --- a/data/item.go +++ b/data/item.go @@ -2,6 +2,7 @@ package data import ( ui "github.com/gizak/termui/v3" + "github.com/lunixbochs/vtclean" "github.com/sqshq/sampler/config" "os" "os/exec" @@ -70,7 +71,9 @@ func (i *Item) execute(variables []string, script string) (string, error) { return "", err } - return string(output), nil + o := string(output) + + return vtclean.Clean(o, false), nil } func (i *Item) initInteractiveShell(v []string) error {