mirror of
https://github.com/moby/moby.git
synced 2025-12-17 00:02:44 +03:00
Add TERM env var to exec
When the `-t` flag is passed on exec make sure to add the TERM env var to mirror the expected configuration from run. Fixes #9299 Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -68,3 +68,26 @@ func (s *DockerSuite) TestExecTTY(c *check.C) {
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(bytes.Contains(buf, []byte("hello")), checker.Equals, true, check.Commentf(string(buf[:read])))
|
||||
}
|
||||
|
||||
// Test the the TERM env var is set when -t is provided on exec
|
||||
func (s *DockerSuite) TestExecWithTERM(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux, SameHostDaemon)
|
||||
out, _ := dockerCmd(c, "run", "-id", "busybox", "/bin/cat")
|
||||
contID := strings.TrimSpace(out)
|
||||
cmd := exec.Command(dockerBinary, "exec", "-t", contID, "sh", "-c", "if [ -z $TERM ]; then exit 1; else exit 0; fi")
|
||||
if err := cmd.Run(); err != nil {
|
||||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
}
|
||||
|
||||
// Test that the TERM env var is not set on exec when -t is not provided, even if it was set
|
||||
// on run
|
||||
func (s *DockerSuite) TestExecWithNoTERM(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux, SameHostDaemon)
|
||||
out, _ := dockerCmd(c, "run", "-itd", "busybox", "/bin/cat")
|
||||
contID := strings.TrimSpace(out)
|
||||
cmd := exec.Command(dockerBinary, "exec", contID, "sh", "-c", "if [ -z $TERM ]; then exit 0; else exit 1; fi")
|
||||
if err := cmd.Run(); err != nil {
|
||||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user