diff --git a/news/capture-stdout-without-stderr.rst b/news/capture-stdout-without-stderr.rst new file mode 100644 index 000000000..fef316267 --- /dev/null +++ b/news/capture-stdout-without-stderr.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* $() no longer silently captures stderr + +**Security:** + +* diff --git a/tests/procs/test_specs.py b/tests/procs/test_specs.py index d05b21685..e7f047e4b 100644 --- a/tests/procs/test_specs.py +++ b/tests/procs/test_specs.py @@ -47,6 +47,18 @@ def test_cmds_to_specs_thread_subproc(xession): assert specs[0].cls is ProcProxy +@pytest.mark.parametrize("thread_subprocs", [True, False]) +def test_cmds_to_specs_capture_stdout_not_stderr(thread_subprocs): + env = XSH.env + cmds = (["ls", "/root"],) + + env["THREAD_SUBPROCS"] = thread_subprocs + + specs = cmds_to_specs(cmds, captured="stdout") + assert specs[0].stdout is not None + assert specs[0].stderr is None + + @skip_if_on_windows @pytest.mark.parametrize( "thread_subprocs, capture_always", list(itertools.product((True, False), repeat=2)) diff --git a/xonsh/procs/specs.py b/xonsh/procs/specs.py index c8dc235f3..e5384fa7d 100644 --- a/xonsh/procs/specs.py +++ b/xonsh/procs/specs.py @@ -776,6 +776,8 @@ def _update_last_spec(last): # set standard error if last.stderr is not None: pass + elif captured == "stdout": + pass elif captured == "object": r, w = os.pipe() last.stderr = safe_open(w, "w")