File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 2
2
"""List all repositories."""
3
3
import argparse
4
4
import json
5
+ import os
5
6
import subprocess
7
+ import sys
6
8
from dataclasses import dataclass
7
9
from pprint import pprint
8
10
# Use `typing.*` instead of `collections.abc` to support older Python versions.
@@ -20,8 +22,15 @@ def main():
20
22
commands = list_commands ()
21
23
command = commands [args .type ]
22
24
23
- for output in command ():
24
- print (output )
25
+ try :
26
+ for output in command ():
27
+ print (output )
28
+ except BrokenPipeError :
29
+ # see docs here:
30
+ # https://docs.python.org/3/library/signal.html#note-on-sigpipe
31
+ devnull = os .open (os .devnull , os .O_WRONLY )
32
+ os .dup2 (devnull , sys .stdout .fileno ())
33
+ sys .exit (1 ) # Python exits with error code 1 on EPIPE
25
34
26
35
27
36
@dataclass
You can’t perform that action at this time.
0 commit comments