Only make docker sessions interactive if stdin is a TTY.
authorCarl Hetherington <cth@carlh.net>
Tue, 17 Mar 2020 08:37:11 +0000 (09:37 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 17 Mar 2020 08:37:11 +0000 (09:37 +0100)
cdist

diff --git a/cdist b/cdist
index 4c21cef55fc3847d33fc028fe2ac51835527db08..39568d64f154ce068aa73afa5949cd551e8d447b 100755 (executable)
--- 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()