From c7f28855ca4f02acc3827b61aab67222d313b723 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Fri, 22 Mar 2019 21:28:57 +0100 Subject: [PATCH] fix: clear handler caused issues on some terminals, fixed by using os specific clear command --- session/session_core_handlers.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/session/session_core_handlers.go b/session/session_core_handlers.go index 09da1776..51f40be0 100644 --- a/session/session_core_handlers.go +++ b/session/session_core_handlers.go @@ -4,7 +4,9 @@ import ( "bufio" "fmt" "os" + "os/exec" "path/filepath" + "runtime" "sort" "strconv" "strings" @@ -249,13 +251,14 @@ func (s *Session) readHandler(args []string, sess *Session) error { } func (s *Session) clsHandler(args []string, sess *Session) error { - // fixes a weird bug which causes the screen not to be fully - // cleared if a "clear; net.show" commands chain is executed - // in the interactive session. - for i := 0; i < 180; i++ { - fmt.Println() + cmd := "clear" + if runtime.GOOS == "windows" { + cmd = "cls" } - readline.ClearScreen(s.Input.Stdout()) + + c := exec.Command(cmd) + c.Stdout = os.Stdout + c.Run() return nil }