Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Warn if running in TTY on windows
Browse files Browse the repository at this point in the history
Signed-off-by: Dana Pieluszczak <[email protected]>
danajp committed Nov 28, 2022
1 parent 68b1e2a commit 64a3930
Showing 4 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cmd/argoexec/commands/emissary.go
Original file line number Diff line number Diff line change
@@ -247,7 +247,7 @@ func startCommand(name string, args []string, template *wfv1.Template) (*exec.Cm
origCloser()
}

return command, cmdCloser, nil
return command, closer, nil
}

func saveArtifact(srcPath string) error {
17 changes: 17 additions & 0 deletions workflow/executor/os-specific/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package os_specific

import (
"io"
"os/exec"
)

func simpleStart(cmd *exec.Cmd, stdout io.Writer, stderr io.Writer) (func(), error) {
cmd.Stdout = stdout
cmd.Stderr = stderr

if err := cmd.Start(); err != nil {
return nil, err
}

return func() {}, nil
}
13 changes: 3 additions & 10 deletions workflow/executor/os-specific/command_unix.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build !windows
package os_specific
//go:build linux || darwin

package os_specific

import (
"io"
@@ -27,14 +27,7 @@ func StartCommand(cmd *exec.Cmd, stdin *os.File, stdout io.Writer, stderr io.Wri
// the group leader already
Setpgid(cmd.SysProcAttr)

cmd.Stdout = stdout
cmd.Stderr = stderr

if err := cmd.Start(); err != nil {
return nil, err
}

return closer, nil
return simpleStart(cmd, stdout, stderr)
}

ptmx, err := pty.Start(cmd)
20 changes: 9 additions & 11 deletions workflow/executor/os-specific/command_windows.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
//go:build windows
package os_specific

import (
"io"
"os"
"os/exec"
"io"
)

func StartCommand(cmd *exec.Cmd, stdin *os.File, stdout io.Writer, stderr io.Writer) (func(), error) {
closer := func() {}
log "github.com/sirupsen/logrus"
"golang.org/x/term"
)

cmd.Stdout = stdout
cmd.Stderr = stderr
var logger = log.WithField("argo", true)

if err := cmd.Start(); err != nil {
return nil, err
func StartCommand(cmd *exec.Cmd, stdin *os.File, stdout io.Writer, stderr io.Writer) (func(), error) {
if term.IsTerminal(int(stdin.Fd())) {
logger.Warn("TTY detected but is not supported on windows")
}

return closer, nil
return simpleStart(cmd, stdout, stderr)
}

0 comments on commit 64a3930

Please sign in to comment.