Fix for capturing internal terminal pty output

Fixes #2879
This commit is contained in:
Zachary Yedidia 2023-08-31 07:09:40 -07:00
parent a78c2c3509
commit d0f0b95e45

View file

@ -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,
}
}