]> thyrsus.com Git - ctopy.git/commitdiff
Exit gracefully on keyboard interrupt.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 19 Oct 2010 09:53:59 +0000 (05:53 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 19 Oct 2010 09:53:59 +0000 (05:53 -0400)
ctopy

diff --git a/ctopy b/ctopy
index 2a380a1dc3577bedf3538237ac435f1366ac14c3..98f11b031047705f39629dee5c6aae643aea7bc7 100755 (executable)
--- 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