Kaynağa Gözat

Gracefully handle keyboard interrupt

Previously, a keyboard interrupt would result in a corrupted terminal.
This would manifest when doing "cdiff --log" on somewhat large
repositories.
Steven Myint 11 yıl önce
ebeveyn
işleme
6e9d22e205
1 değiştirilmiş dosya ile 5 ekleme ve 2 silme
  1. 5
    2
      cdiff.py

+ 5
- 2
cdiff.py Dosyayı Görüntüle

@@ -536,8 +536,11 @@ def markup_to_pager(stream, opts):
536 536
     # args stolen fron git source: github.com/git/git/blob/master/pager.c
537 537
     pager = subprocess.Popen(['less', '-FRSX'],
538 538
             stdin=subprocess.PIPE, stdout=sys.stdout)
539
-    for line in color_diff:
540
-        pager.stdin.write(line.encode('utf-8'))
539
+    try:
540
+        for line in color_diff:
541
+            pager.stdin.write(line.encode('utf-8'))
542
+    except KeyboardInterrupt:
543
+        pass
541 544
 
542 545
     pager.stdin.close()
543 546
     pager.wait()