Windows Pty (#206)

Add Windows Pty support, so the terminal works properly on windows
machines
This commit is contained in:
Sylvie Crowe
2024-08-09 18:49:35 -07:00
committed by GitHub
parent 4498ca8e9d
commit c192fe2663
9 changed files with 98 additions and 59 deletions
+9 -2
View File
@@ -2,9 +2,9 @@ package shellexec
import (
"io"
"os"
"os/exec"
"github.com/creack/pty"
"golang.org/x/crypto/ssh"
)
@@ -16,10 +16,12 @@ type ConnInterface interface {
StdoutPipe() (io.ReadCloser, error)
StderrPipe() (io.ReadCloser, error)
SetSize(w int, h int) error
pty.Pty
}
type CmdWrap struct {
Cmd *exec.Cmd
pty.Pty
}
func (cw CmdWrap) Kill() {
@@ -54,13 +56,18 @@ func (cw CmdWrap) StderrPipe() (io.ReadCloser, error) {
}
func (cw CmdWrap) SetSize(w int, h int) error {
err := pty.Setsize(cw.Pty, &pty.Winsize{Rows: uint16(w), Cols: uint16(h)})
if err != nil {
return err
}
return nil
}
type SessionWrap struct {
Session *ssh.Session
StartCmd string
Tty *os.File
Tty pty.Tty
pty.Pty
}
func (sw SessionWrap) Kill() {