From 7fe1f1ecd84caa3a7c3b82f8b21d5fca790888e6 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 17 Mar 2020 09:37:11 +0100 Subject: [PATCH] Only make docker sessions interactive if stdin is a TTY. --- cdist | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist b/cdist index 4c21cef..39568d6 100755 --- a/cdist +++ b/cdist @@ -553,7 +553,8 @@ class DockerTarget(Target): def command(self, cmd): dir = os.path.join(self.directory, os.path.relpath(os.getcwd(), self.directory)) - command('%s exec %s -i -t %s /bin/bash -c \'export %s; cd %s; %s\'' % (config.docker(), self._user_tag(), self.container, self.variables_string(), dir, cmd)) + interactive_flag = '-i ' if sys.stdin.isatty() else '' + command('%s exec %s %s -t %s /bin/bash -c \'export %s; cd %s; %s\'' % (config.docker(), self._user_tag(), interactive_flag, self.container, self.variables_string(), dir, cmd)) def cleanup(self): super(DockerTarget, self).cleanup() -- 2.30.2