Skip to content

Commit e50c32e

Browse files
committed
BUG: Exit with status 0 even if stdin closes abruptly
Discovered with: diff-logs < file.log | head -n 2
1 parent e8f80b2 commit e50c32e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

diff-logs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@
5454
for line in sys.stdin:
5555
for pattern, replacement in PATTERNS.items():
5656
line = re.sub(pattern, replacement, line)
57-
print(line, end='')
57+
try:
58+
print(line, end='')
59+
except BrokenPipeError:
60+
break

0 commit comments

Comments
 (0)