summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
Diffstat (limited to 'cmd2/cmd2.py')
-rwxr-xr-xcmd2/cmd2.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 8165f411..4528b14e 100755
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -2182,9 +2182,33 @@ class Cmd(cmd.Cmd):
# statement = self.parser_manager.parsed(line) # deleteme
statement = self.command_parser.parseString(line)
while statement.multilineCommand and not statement.terminator:
- line = '%s\n%s' % (statement.raw,
- self.pseudo_raw_input(self.continuation_prompt))
+ if not self.quit_on_sigint:
+ try:
+ newline = self.pseudo_raw_input(self.continuation_prompt)
+ if newline == 'eof':
+ # they entered either a blank line, or we hit an EOF
+ # for some other reason. Turn the literal 'eof'
+ # into a blank line, which serves as a command
+ # terminator
+ newline = '\n'
+ self.poutput(newline)
+ line = '%s\n%s' % (statement.raw, newline)
+ except KeyboardInterrupt:
+ self.poutput('^C')
+ statement = self.command_parser.parseString('')
+ break
+ else:
+ newline = self.pseudo_raw_input(self.continuation_prompt)
+ if newline == 'eof':
+ # they entered either a blank line, or we hit an EOF
+ # for some other reason. Turn the literal 'eof'
+ # into a blank line, which serves as a command
+ # terminator
+ newline = '\n'
+ self.poutput(newline)
+ line = '%s\n%s' % (statement.raw, newline)
statement = self.command_parser.parseString(line)
+
if not statement.command:
raise EmptyStatement()
return statement