Skip to content

Commit

Permalink
fix: update ssh example to use tty instead of pty
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Jun 15, 2022
1 parent 4e9068d commit c15acc0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions examples/ssh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ import (

type sshOutput struct {
ssh.Session
pty *os.File
tty *os.File
}

func (s *sshOutput) Write(p []byte) (int, error) {
return s.Session.Write(p)
}

func (s *sshOutput) Fd() uintptr {
return s.pty.Fd()
return s.tty.Fd()
}

type sshEnviron struct {
Expand All @@ -40,13 +44,13 @@ func (s *sshEnviron) Environ() []string {

func outputFromSession(s ssh.Session) *termenv.Output {
sshPty, _, _ := s.Pty()
pty, _, err := pty.Open()
_, tty, err := pty.Open()
if err != nil {
panic(err)
}
o := &sshOutput{
Session: s,
pty: pty,
tty: tty,
}
environ := s.Environ()
environ = append(environ, fmt.Sprintf("TERM=%s", sshPty.Term))
Expand Down

0 comments on commit c15acc0

Please sign in to comment.