diff --git a/news/tq.rst b/news/tq.rst new file mode 100644 index 000000000..ffa62d0ca --- /dev/null +++ b/news/tq.rst @@ -0,0 +1,13 @@ +**Added:** None + +**Changed:** None + +**Deprecated:** None + +**Removed:** None + +**Fixed:** + +* Fixed issue with starting triple quote strings being run as a command. + +**Security:** None diff --git a/tests/test_tools.py b/tests/test_tools.py index 2a70e6d52..8c1323766 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -403,6 +403,7 @@ mom""" " --option2 value2 \\\n" " --optionZ valueZ", 1, "echo --option1 value1 --option2 value2 --optionZ valueZ", 3), +('"""\n', 0, '"""', 1), ] @pytest.mark.parametrize('src, idx, exp_line, exp_n', LOGICAL_LINE_CASES) diff --git a/xonsh/tools.py b/xonsh/tools.py index 879c9832c..0cbea3b77 100644 --- a/xonsh/tools.py +++ b/xonsh/tools.py @@ -445,7 +445,7 @@ def get_logical_line(lines, idx): start = idx line = lines[idx] open_triple = _have_open_triple_quotes(line) - while (line.endswith(linecont) or open_triple) and idx < nlines: + while (line.endswith(linecont) or open_triple) and idx < nlines - 1: n += 1 idx += 1 if line.endswith(linecont):