diff --git a/acid/__main__.py b/acid/__main__.py index 1e65466..43ea8ae 100644 --- a/acid/__main__.py +++ b/acid/__main__.py @@ -8,7 +8,6 @@ """ import os -import signal import argparse from acid.parser import Parser, tokenize @@ -65,7 +64,6 @@ def compile(path): def interactive(path=None): repl = REPL() - signal.signal(signal.SIGINT, lambda *_: repl.quit()) if path is not None: repl.load(path) diff --git a/acid/repl/repl.py b/acid/repl/repl.py index aab182b..c078739 100644 --- a/acid/repl/repl.py +++ b/acid/repl/repl.py @@ -112,10 +112,14 @@ def read_command(self): Reads a user-typed REPL command from the input stream. """ - print(self.prompt.format(**self.__dict__), end='') - inp = input() + try: + inp = input(self.prompt.format(**self.__dict__)) + except EOFError: + print('') + inp = '' cmd = parse_repl_line(inp) + return cmd def quit(self): @@ -133,12 +137,15 @@ def run(self, display_header=True): self.running = True - print(self.header) + if display_header: + print(self.header) while self.running: try: cmd = self.read_command() res = cmd.execute(self) + except KeyboardInterrupt: + print('Interrupted.') except Exception as exc: if self.path is None: msg = 'File , input #{repl.cmd_count}'.format(repl=self)