mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
"fixed echo @("foo") > bar"
This commit is contained in:
parent
4d86b7bdec
commit
b76010d620
3 changed files with 24 additions and 3 deletions
|
@ -99,6 +99,10 @@ def test_command_in_func_with_comment():
|
|||
' echo hello # comment\n')
|
||||
yield check_parse, code
|
||||
|
||||
def test_pyeval_redirect():
|
||||
code = 'echo @("foo") > bar\n'
|
||||
yield check_parse, code
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -244,6 +244,14 @@ def test_subproc_toks_capproc():
|
|||
obs = subproc_toks(s, lexer=LEXER, returnline=True)
|
||||
assert_equal(exp, obs)
|
||||
|
||||
def test_subproc_toks_pyeval_redirect():
|
||||
s = 'echo @("foo") > bar'
|
||||
inp = '{0}'.format(s)
|
||||
exp = '![{0}]'.format(s)
|
||||
obs = subproc_toks(inp, lexer=LEXER, returnline=True)
|
||||
assert_equal(exp, obs)
|
||||
|
||||
|
||||
|
||||
def test_subexpr_from_unbalanced_parens():
|
||||
cases = [
|
||||
|
|
|
@ -8,7 +8,8 @@ from collections import Mapping
|
|||
|
||||
from xonsh import ast
|
||||
from xonsh.parser import Parser
|
||||
from xonsh.tools import subproc_toks, END_TOK_TYPES
|
||||
from xonsh.tools import (subproc_toks, END_TOK_TYPES, LPARENS,
|
||||
_is_not_lparen_and_rparen)
|
||||
from xonsh.built_ins import load_builtins, unload_builtins
|
||||
|
||||
|
||||
|
@ -134,10 +135,18 @@ class Execer(object):
|
|||
if RE_END_TOKS.search(line) is None:
|
||||
return None
|
||||
maxcol = None
|
||||
lparens = []
|
||||
self.parser.lexer.input(line)
|
||||
for tok in self.parser.lexer:
|
||||
if tok.type in END_TOK_TYPES or \
|
||||
(tok.type == 'ERRORTOKEN' and ')' in tok.value):
|
||||
if tok.type in LPARENS:
|
||||
lparens.append(tok.type)
|
||||
elif tok.type in END_TOK_TYPES:
|
||||
if _is_not_lparen_and_rparen(lparens, tok):
|
||||
lparens.pop()
|
||||
else:
|
||||
maxcol = tok.lexpos + mincol + 1
|
||||
break
|
||||
elif tok.type == 'ERRORTOKEN' and ')' in tok.value:
|
||||
maxcol = tok.lexpos + mincol + 1
|
||||
break
|
||||
return maxcol
|
||||
|
|
Loading…
Add table
Reference in a new issue