diff options
-rw-r--r-- | cmd2/parsing.py | 9 | ||||
-rw-r--r-- | tests/test_parsing.py | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/cmd2/parsing.py b/cmd2/parsing.py index 9fe8f6eb..655e0c58 100644 --- a/cmd2/parsing.py +++ b/cmd2/parsing.py @@ -256,7 +256,16 @@ class StatementParser: if cur_token.startswith(test_terminator): terminator_pos = pos terminator = test_terminator + # break the inner loop, and we want to break the + # outer loop too break + else: + # this else clause is only run if the inner loop + # didn't execute a break. If it didn't, then + # continue to the next iteration of the outer loop + continue + # inner loop was broken, break the outer + break if terminator: if terminator == LINE_FEED: diff --git a/tests/test_parsing.py b/tests/test_parsing.py index d147c6a1..7b361b7e 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -263,8 +263,8 @@ def test_parse_redirect_inside_terminator(parser): def test_parse_multiple_terminators(parser, line, terminator): statement = parser.parse(line) assert statement.multiline_command == 'multiline' - assert statement.args == 'has | inside' - assert statement.argv == ['multiline', 'has', '|', 'inside'] + assert statement.args == 'with | inside' + assert statement.argv == ['multiline', 'with', '|', 'inside'] assert statement.terminator == terminator def test_parse_unfinished_multiliine_command(parser): |