diff --git a/internal/command/command_virtual.go b/internal/command/command_virtual.go index e9668a96..546b0d2a 100644 --- a/internal/command/command_virtual.go +++ b/internal/command/command_virtual.go @@ -49,6 +49,10 @@ func (c *virtualCommand) Pid() int { return c.cmd.Process.Pid } +func (c *virtualCommand) Stdin() io.Reader { + return c.stdin +} + func (c *virtualCommand) Start(ctx context.Context) (err error) { c.pty, c.tty, err = pty.Open() if err != nil { diff --git a/internal/command/factory.go b/internal/command/factory.go index cd484dc3..3e41597f 100644 --- a/internal/command/factory.go +++ b/internal/command/factory.go @@ -173,12 +173,9 @@ func (f *commandFactory) buildNative(base *base) internalCommand { func (f *commandFactory) buildVirtual(base *base, opts CommandOptions) internalCommand { var stdin io.ReadCloser - - if !isNil(base.Stdin()) { - stdin = &readCloser{r: base.Stdin(), done: make(chan struct{})} - base.stdin = stdin + if in := base.Stdin(); !isNil(in) { + stdin = &readCloser{r: in, done: make(chan struct{})} } - return &virtualCommand{ base: base, isEchoEnabled: opts.EnableEcho,