integrated lexer split into $(cmd)

This commit is contained in:
Anthony Scopatz 2017-02-19 21:02:04 -05:00
parent 4030ed8050
commit a8224d29a2
2 changed files with 24 additions and 2 deletions

17
news/lex.rst Normal file
View file

@ -0,0 +1,17 @@
**Added:**
* The lexer has a new ``split()`` method which splits strings
according to xonsh's rules for whitespace and quotes.
**Changed:** None
**Deprecated:** None
**Removed:** None
**Fixed:**
* The ``@$(cmd)`` operator now correctly splits strings according to
xonsh semantics, rather than just on whitespace using ``str.split()``.
**Security:** None

View file

@ -839,8 +839,13 @@ def subproc_captured_stdout(*cmds):
def subproc_captured_inject(*cmds):
"""Runs a subprocess, capturing the output. Returns a list of
whitespace-separated strings in the stdout that was produced."""
return [i.strip() for i in run_subproc(cmds, captured='stdout').split()]
whitespace-separated strings of the stdout that was produced.
The string is split using xonsh's lexer, rather than Python's str.split()
or shlex.split().
"""
s = run_subproc(cmds, captured='stdout')
toks = builtins.__xonsh_execer__.parser.lexer.split(s)
return toks
def subproc_captured_object(*cmds):