mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Merge pull request #3630 from laloch/fix-linecont
Fix ctx-free parser stripping the trailing newline
This commit is contained in:
commit
a65b940992
3 changed files with 29 additions and 5 deletions
23
news/fix-linecont.rst
Normal file
23
news/fix-linecont.rst
Normal file
|
@ -0,0 +1,23 @@
|
|||
**Added:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Changed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Deprecated:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Removed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* Fixed syntax error in scripts containing line continuation syntax.
|
||||
|
||||
**Security:**
|
||||
|
||||
* <news item>
|
|
@ -289,10 +289,11 @@ def _echo(args):
|
|||
print(' '.join(args))
|
||||
aliases['echo'] = _echo
|
||||
|
||||
echo --option1 \
|
||||
echo --option1 \\
|
||||
--option2
|
||||
""",
|
||||
"--option1 --option2\n",
|
||||
echo missing \\
|
||||
EOL""",
|
||||
"--option1 --option2\nmissing EOL\n",
|
||||
0,
|
||||
),
|
||||
#
|
||||
|
|
|
@ -242,6 +242,8 @@ class Execer(object):
|
|||
last_error_line = e.loc.lineno
|
||||
idx = last_error_line - 1
|
||||
lines = input.splitlines()
|
||||
if input.endswith("\n"):
|
||||
lines.append("")
|
||||
line, nlogical, idx = get_logical_line(lines, idx)
|
||||
if nlogical > 1 and not logical_input:
|
||||
_, sbpline = self._parse_ctx_free(
|
||||
|
@ -254,8 +256,6 @@ class Execer(object):
|
|||
last_error_col += 3
|
||||
input = "\n".join(lines)
|
||||
continue
|
||||
if input.endswith("\n"):
|
||||
lines.append("")
|
||||
if len(line.strip()) == 0:
|
||||
# whitespace only lines are not valid syntax in Python's
|
||||
# interactive mode='single', who knew?! Just ignore them.
|
||||
|
|
Loading…
Add table
Reference in a new issue