From d0f0b95e45aa96bef226a57d0a9ff5825ec389c9 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Thu, 31 Aug 2023 07:09:40 -0700 Subject: [PATCH] Fix for capturing internal terminal pty output Fixes #2879 --- internal/shell/terminal.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/shell/terminal.go b/internal/shell/terminal.go index bae3eef6..423bb736 100644 --- a/internal/shell/terminal.go +++ b/internal/shell/terminal.go @@ -2,7 +2,6 @@ package shell import ( "bytes" - "io" "os/exec" "strconv" @@ -80,6 +79,7 @@ func (t *Terminal) Start(execCmd []string, getOutput bool, wait bool, callback f if getOutput { t.output = bytes.NewBuffer([]byte{}) } + cmd.Stdout = t.output Term, _, err := terminal.Start(&t.State, cmd) if err != nil { return err @@ -129,12 +129,11 @@ func (t *Terminal) Close() { // call the lua function that the user has given as a callback if t.getOutput { if t.callback != nil { - b, _ := io.ReadAll(t.Term.File()) Jobs <- JobFunction{ Function: func(out string, args []interface{}) { t.callback(out) }, - Output: string(b), + Output: t.output.String(), Args: nil, } }