Skip to content

Commit 268f0f6

Browse files
author
rkern
committed
BUG: Gracefully handle the case when a user pipes the output to a pager and exits the pager. Thanks to Brandon Craig Rhodes for the patch.
git-svn-id: https://svn.enthought.com/svn/sandbox/grin/trunk@76 b5260ef8-a2c4-4e91-82fd-f242746c304a
1 parent 8f8a7cf commit 268f0f6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

grin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,12 @@ def grin_main(argv=None):
10261026
sys.stdout.write(report)
10271027
except KeyboardInterrupt:
10281028
raise SystemExit(0)
1029+
except IOError as e:
1030+
if 'Broken pipe' in str(e):
1031+
# The user is probably piping to a pager like less(1) and has exited
1032+
# it. Just exit.
1033+
raise SystemExit(0)
1034+
raise
10291035

10301036
def print_line(filename):
10311037
print filename

0 commit comments

Comments
 (0)