Skip to content

Commit

Permalink
Merge pull request #30 from zigarn/interrupt-command
Browse files Browse the repository at this point in the history
Allow to interrupt running command with CTRL-C w/o interrupting session
  • Loading branch information
sloria committed May 9, 2018
2 parents b1e9b92 + 9b56d62 commit 87a6069
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions doitlive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,14 @@ def run_command(cmd, shell=None, aliases=None, envvars=None, test_mode=False):
cmd_line = cmd + '\n'
fp.write(ensure_utf(cmd_line))
fp.flush()
if test_mode:
output = subprocess.check_output([shell, fp.name])
echo(output)
else:
return subprocess.call([shell, fp.name])
try:
if test_mode:
output = subprocess.check_output([shell, fp.name])
echo(output)
else:
return subprocess.call([shell, fp.name])
except KeyboardInterrupt:
pass


def wait_for(chars):
Expand Down

0 comments on commit 87a6069

Please sign in to comment.