diff --git a/lib/ClusterShell/CLI/Clush.py b/lib/ClusterShell/CLI/Clush.py index e922ce54..54bf32f6 100755 --- a/lib/ClusterShell/CLI/Clush.py +++ b/lib/ClusterShell/CLI/Clush.py @@ -676,13 +676,13 @@ def run_command(task, cmd, ns, timeout, display, remote, trytree): # this is the simpler but faster output handler handler = DirectOutputHandler(display) + stdin = task.default("USER_stdin_worker") worker = task.shell(cmd, nodes=ns, handler=handler, timeout=timeout, - remote=remote, tree=trytree) + remote=remote, tree=trytree, stdin=stdin) if ns is None: worker.set_key('LOCAL') - if task.default("USER_stdin_worker"): + if stdin: bind_stdin(worker, display) - task.resume() def run_copy(task, sources, dest, ns, timeout, preserve_flag, display): @@ -1032,9 +1032,6 @@ def main(): # Enable stdout/stderr separation task.set_default("stderr", not options.gatherall) - # Prevent reading from stdin? - task.set_default("stdin", not options.nostdin) - # Disable MsgTree buffering if not gathering outputs task.set_default("stdout_msgtree", display.gather or display.line_mode) diff --git a/tests/CLIClushTest.py b/tests/CLIClushTest.py index 57dfae11..c987d1cb 100644 --- a/tests/CLIClushTest.py +++ b/tests/CLIClushTest.py @@ -606,6 +606,18 @@ def test_039_conf_option(self): "foo[1-10]", "echo ok"], b"", b"---------------\nfoo[1-10]\n---------------\nok\n") + def test_040_stdin_eof(self): + """test clush (stdin eof)""" + # should not block if connection to stdin cannot be established + # or of --nostdin is specified + self._clush_t(["-w", HOSTNAME, "cat"], None, b'') + self._clush_t(["-w", HOSTNAME, "--nostdin", "cat"], None, b'') + setattr(ClusterShell.CLI.Clush, '_f_user_interaction', True) + try: + self._clush_t(["-w", HOSTNAME, "cat"], None, b'') + finally: + delattr(ClusterShell.CLI.Clush, '_f_user_interaction') + class CLIClushTest_B_StdinFailure(unittest.TestCase): """Unit test class for testing CLI/Clush.py and stdin failure"""