소스 검색

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 년 전
부모
커밋
6e9d22e205
1개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 5
    2
      cdiff.py

+ 5
- 2
cdiff.py 파일 보기

@@ -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()