fix: Terminal emulation used by SSH sessions (#3473)

Fixes #3371
This commit is contained in:
Mathias Fredriksson
2022-09-12 19:27:51 +03:00
committed by GitHub
parent b4c29f34c3
commit 09da3858ce
15 changed files with 387 additions and 82 deletions
+16 -2
View File
@@ -4,8 +4,22 @@ import (
"os/exec"
)
// StartOption represents a configuration option passed to Start.
type StartOption func(*startOptions)
type startOptions struct {
ptyOpts []Option
}
// WithPTYOption applies the given options to the underlying PTY.
func WithPTYOption(opts ...Option) StartOption {
return func(o *startOptions) {
o.ptyOpts = append(o.ptyOpts, opts...)
}
}
// Start the command in a TTY. The calling code must not use cmd after passing it to the PTY, and
// instead rely on the returned Process to manage the command/process.
func Start(cmd *exec.Cmd) (PTY, Process, error) {
return startPty(cmd)
func Start(cmd *exec.Cmd, opt ...StartOption) (PTY, Process, error) {
return startPty(cmd, opt...)
}