diff --git a/cli/cmd/exec.go b/cli/cmd/exec.go index 7120b1c75..ef1ad8eea 100644 --- a/cli/cmd/exec.go +++ b/cli/cmd/exec.go @@ -19,6 +19,7 @@ package cmd import ( "context" "fmt" + "os" "strings" "github.com/containerd/console" @@ -56,9 +57,8 @@ func runExec(ctx context.Context, opts execOpts, name string, command string) er return errors.Wrap(err, "cannot connect to backend") } - con := console.Current() - if opts.Tty { + con := console.Current() if err := con.SetRaw(); err != nil { return err } @@ -67,7 +67,7 @@ func runExec(ctx context.Context, opts execOpts, name string, command string) er fmt.Println("Unable to close the console") } }() + return c.ContainerService().Exec(ctx, name, command, con, con) } - - return c.ContainerService().Exec(ctx, name, command, con, con) + return c.ContainerService().Exec(ctx, name, command, os.Stdin, os.Stdout) } diff --git a/tests/aci-e2e/e2e-aci_test.go b/tests/aci-e2e/e2e-aci_test.go index 04e30a463..dfd6d3835 100644 --- a/tests/aci-e2e/e2e-aci_test.go +++ b/tests/aci-e2e/e2e-aci_test.go @@ -151,11 +151,8 @@ func (s *E2eACISuite) TestACIBackend() { }) s.T().Run("exec command", func(t *testing.T) { - output := s.NewDockerCommand("exec", testContainerName, "pwd").ExecOrDie() - Expect(output).To(ContainSubstring("/")) - - output = s.NewDockerCommand("exec", testContainerName, "echo", "fail_with_argument").ExecOrDie() - Expect(output).To(ContainSubstring("ACI exec command does not accept arguments to the command. " + + _, err := s.NewDockerCommand("exec", testContainerName, "echo", "fail_with_argument").Exec() + Expect(err.Error()).To(ContainSubstring("ACI exec command does not accept arguments to the command. " + "Only the binary should be specified")) })