From e672ffaf799bac59bfa420144968bedbb37b632d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 19 Oct 2010 05:53:59 -0400 Subject: [PATCH] Exit gracefully on keyboard interrupt. --- ctopy | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ctopy b/ctopy index 2a380a1..98f11b0 100755 --- a/ctopy +++ b/ctopy @@ -1302,10 +1302,13 @@ if __name__ == "__main__": elif (switch == '-t'): shorthands["type"] += r"|\b" + val + r"\b" - code = sys.stdin.read() - if debug >= 2: - print "Input is: %s" % `code` - text = ctopy(code) - if debug: - print "Output:" - sys.stdout.write(text) + try: + code = sys.stdin.read() + if debug >= 2: + print "Input is: %s" % `code` + text = ctopy(code) + if debug: + print "Output:" + sys.stdout.write(text) + except KeyboardInterrupt: + pass -- 2.43.0