cleanup escape codes for regular and interactive shell sampling

This commit is contained in:
sqshq 2019-08-23 22:33:34 -04:00
parent 5b0b2291d2
commit 9c00af5e50
2 changed files with 6 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"bufio" "bufio"
"errors" "errors"
"fmt" "fmt"
"github.com/lunixbochs/vtclean"
"io" "io"
"os/exec" "os/exec"
"strings" "strings"
@ -118,7 +119,7 @@ func (s *BasicInteractiveShell) execute() (string, error) {
if errorText.Len() > 0 { if errorText.Len() > 0 {
return "", errors.New(errorText.String()) return "", errors.New(errorText.String())
} }
return s.item.transform(resultText.String()) return s.item.transform(vtclean.Clean(resultText.String(), false))
} }
} }
} }

View File

@ -2,6 +2,7 @@ package data
import ( import (
ui "github.com/gizak/termui/v3" ui "github.com/gizak/termui/v3"
"github.com/lunixbochs/vtclean"
"github.com/sqshq/sampler/config" "github.com/sqshq/sampler/config"
"os" "os"
"os/exec" "os/exec"
@ -70,7 +71,9 @@ func (i *Item) execute(variables []string, script string) (string, error) {
return "", err return "", err
} }
return string(output), nil o := string(output)
return vtclean.Clean(o, false), nil
} }
func (i *Item) initInteractiveShell(v []string) error { func (i *Item) initInteractiveShell(v []string) error {