diff --git a/comment.py b/comment.py index 291e940..1f70633 100755 --- a/comment.py +++ b/comment.py @@ -19,7 +19,6 @@ import antlr4 import configparser import logging import readline -import signal import sys from CommentMacroLexer import CommentMacroLexer @@ -58,20 +57,18 @@ def comment(text): walker.walk(oscMacro, tree) -def orderly_exit(): - logger.info('Goodbye.') - sys.exit(0) - - if __name__ == '__main__': - signal.signal(signal.SIGINT, orderly_exit) if len(sys.argv) > 1: logger.debug("found macro at argv[1]") comment(sys.argv[1]) else: while True: - text = input("comment# ") + try: + text = input("comment# ") + except KeyboardInterrupt: + print() + sys.exit(0) if text == 'exit': - orderly_exit() + sys.exit(0) else: comment(text)