Skip to content

Commit

Permalink
Fix commentecho when comment has a quote character
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed Dec 23, 2018
1 parent 690a54f commit c570cc3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
---------

4.2.1 (unreleased)
******************

Bug fixes:

* Fix behavior of ``commentecho`` when a comment includes quote characters.

4.2.0 (2018-11-08)
******************

Expand Down
8 changes: 6 additions & 2 deletions doitlive/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,16 @@ def run(commands, shell=None, prompt_template='default', speed=1,
i = 0
while i < len(commands):
command = commands[i].strip()
command_as_list = shlex.split(ensure_utf8(command))
i += 1
if not command:
continue
is_comment = command.startswith('#')
if not is_comment:
command_as_list = shlex.split(ensure_utf8(command))
else:
command_as_list = None
shell_match = SHELL_RE.match(command)
if command.startswith('#'):
if is_comment:
# Parse comment magic
match = OPTION_RE.match(command)
if match:
Expand Down
2 changes: 1 addition & 1 deletion tests/sessions/commentecho.session
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# foo
#doitlive commentecho: true
echo
# bar
# bar'
#doitlive commentecho: false
# baz
2 changes: 1 addition & 1 deletion tests/test_doitlive.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_commentecho_magic_comment(self, runner):
)
assert result.exit_code == 0
assert 'foo' not in result.output
assert 'bar' in result.output
assert "bar'" in result.output
assert 'baz' not in result.output

def test_esc_key_aborts(self, runner):
Expand Down

0 comments on commit c570cc3

Please sign in to comment.