From: Carl Hetherington Date: Tue, 17 Mar 2020 08:37:11 +0000 (+0100) Subject: Only make docker sessions interactive if stdin is a TTY. X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=42dbd35840cd734d4b73f0c9d49f401706322938;p=cdist.git Only make docker sessions interactive if stdin is a TTY. --- 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()