I'm going to revert #5423 because it was regress -
https://github.com/xonsh/xonsh/issues/5466 - and we need to fix parser
instead of resolver.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
This commit is contained in:
Andy Kipp 2024-05-31 22:59:59 +02:00 committed by GitHub
parent b0b1fe0ac1
commit c9046ab3f6
Failed to generate hash of commit
4 changed files with 2 additions and 49 deletions

View file

@ -1,23 +0,0 @@
**Added:**
* <news item>
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* Fixed redirect with python substitution e.g. ``echo 1 > @('/tmp/file')`` is working now.
**Security:**
* <news item>

View file

@ -353,14 +353,6 @@ def test_on_command_not_found_doesnt_fire_in_non_interactive_mode(xession):
assert not fired
def test_redirect_to_substitution(xession):
s = SubprocSpec.build(
# `echo hello > @('file')`
["echo", "hello", (">", ["file"])]
)
assert s.stdout.name == "file"
def test_partial_args_from_classmethod(xession):
class Class:
@classmethod

View file

@ -74,6 +74,7 @@ def patched_events(monkeypatch, xonsh_events, xonsh_session):
("!(echo hi | grep x)", "", "", ""),
),
)
@pytest.mark.flaky(reruns=3, reruns_delay=2)
def test_command_pipeline_capture(cmdline, stdout, stderr, raw_stdout, xonsh_execer):
pipeline: CommandPipeline = xonsh_execer.eval(cmdline)
assert pipeline.out == stdout

View file

@ -223,9 +223,6 @@ def _parse_redirects(r, loc=None):
def _redirect_streams(r, loc=None):
"""Returns stdin, stdout, stderr tuple of redirections."""
if isinstance(loc, list):
raise Exception(f"Unsupported redirect: {r!r} {loc!r}")
stdin = stdout = stderr = None
no_ampersand = r.replace("&", "")
# special case of redirecting stderr to stdout
@ -674,21 +671,7 @@ class SubprocSpec:
"""Weave a list of arguments into a command."""
resolved_cmd = []
for c in self.cmd:
if (
isinstance(c, tuple)
and len(c) == 2
and isinstance(c[1], list)
and len(c[1]) == 1
):
# Redirect case e.g. `> file`
resolved_cmd.append(
(
c[0],
c[1][0],
)
)
else:
resolved_cmd += c if isinstance(c, list) else [c]
resolved_cmd += c if isinstance(c, list) else [c]
self.cmd = resolved_cmd
def resolve_redirects(self):