This commit is contained in:
a 2024-06-22 21:40:24 +02:00
parent 93e493afd0
commit ca3b57a6ed

View file

@ -1021,19 +1021,25 @@ def cmds_to_specs(cmds, captured=False, envs=None):
# Apply boundary conditions
if not XSH.env.get("XONSH_CAPTURE_ALWAYS"):
# Make sure sub-specs are always captured.
# I.e. ![some_alias | grep x] $(some_alias)
specs_to_capture = specs if captured in STDOUT_CAPTURE_KINDS else specs[:-1]
for spec in specs_to_capture:
if spec.env is None:
spec.env = {"XONSH_CAPTURE_ALWAYS": True}
else:
spec.env.setdefault("XONSH_CAPTURE_ALWAYS", True)
# Make sure sub-specs are always captured in case:
# `![some_alias | grep x]`, `$(some_alias)`, `some_alias > file`.
last = spec
specs_to_capture = specs if captured in STDOUT_CAPTURE_KINDS or last.stdout else specs[:-1]
_set_specs_capture_always(specs_to_capture)
_update_last_spec(specs[-1])
return specs
def _set_specs_capture_always(specs_to_capture):
"""Set XONSH_CAPTURE_ALWAYS for all specs."""
for spec in specs_to_capture:
if spec.env is None:
spec.env = {"XONSH_CAPTURE_ALWAYS": True}
else:
spec.env.setdefault("XONSH_CAPTURE_ALWAYS", True)
def _shell_set_title(cmds):
if XSH.env.get("XONSH_INTERACTIVE") and XSH.shell is not None:
# context manager updates the command information that gets