Stop $() from silently capturing stderr (#4336)

* Stop $() from silently capturing stderr

* Add test
This commit is contained in:
Peter Ye 2021-06-24 09:43:21 -04:00 committed by GitHub
parent 9b79e4186e
commit 86f02c0341
Failed to generate hash of commit
3 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,23 @@
**Added:**
* <news item>
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* $() no longer silently captures stderr
**Security:**
* <news item>

View file

@ -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))

View file

@ -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")