summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-13 17:39:37 -0400
committerGitHub <noreply@github.com>2018-03-13 17:39:37 -0400
commitfe15d07eaaf6501a1acf9e53a1b41dff3810caf8 (patch)
tree9d78a9b4ae804e38c2cdf05269996cda54310f66 /cmd2.py
parent60f27ef374135e7175a811838f47ab880a05c390 (diff)
parent082154fd0aa9c4d931da303c6ef57a98790b10fe (diff)
downloadcmd2-git-fe15d07eaaf6501a1acf9e53a1b41dff3810caf8.tar.gz
Merge branch 'master' into fix/submenu-require-shares
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/cmd2.py b/cmd2.py
index 4d6ec985..519d9925 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -1016,6 +1016,7 @@ class Cmd(cmd.Cmd):
allow_cli_args = True # Should arguments passed on the command-line be processed as commands?
allow_redirection = True # Should output redirection and pipes be allowed
default_to_shell = False # Attempt to run unrecognized commands as shell commands
+ quit_on_sigint = True # Quit the loop on interrupt instead of just resetting prompt
reserved_words = []
# Attributes which ARE dynamically settable at runtime
@@ -1889,7 +1890,14 @@ class Cmd(cmd.Cmd):
self.poutput('{}{}'.format(self.prompt, line))
else:
# Otherwise, read a command from stdin
- line = self.pseudo_raw_input(self.prompt)
+ if not self.quit_on_sigint:
+ try:
+ line = self.pseudo_raw_input(self.prompt)
+ except KeyboardInterrupt:
+ self.poutput('^C')
+ line = ''
+ else:
+ line = self.pseudo_raw_input(self.prompt)
# Run the command along with all associated pre and post hooks
stop = self.onecmd_plus_hooks(line)