diff options
author | kotfu <kotfu@kotfu.net> | 2018-04-23 22:02:58 -0600 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2018-04-23 22:02:58 -0600 |
commit | 4cee87baf6df2896c60d2d3a8811e9e65ed24c84 (patch) | |
tree | 8cafd8fe4517a84bebf04fd368a6f06aeb52f33d /cmd2/cmd2.py | |
parent | 4411d8d68c57e8cfca323b80369a8d3c5f11c9d4 (diff) | |
download | cmd2-git-4cee87baf6df2896c60d2d3a8811e9e65ed24c84.tar.gz |
Fix some old bugs and bad behavior in multiline input
Diffstat (limited to 'cmd2/cmd2.py')
-rwxr-xr-x | cmd2/cmd2.py | 28 |
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 |