Skip to content

Commit 251e7da

Browse files
jszakmeistergitster
authored andcommitted
diff-highlight: exit when a pipe is broken
While using diff-highlight with other tools, I have discovered that Python ignores SIGPIPE by default. Unfortunately, this also means that tools attempting to launch a pager under Python--and don't realize this is happening--means that the subprocess inherits this setting. In this case, it means diff-highlight will be launched with SIGPIPE being ignored. Let's work with those broken scripts by restoring the default SIGPIPE handler. Signed-off-by: John Szakmeister <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eeff891 commit 251e7da

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

contrib/diff-highlight/diff-highlight

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ my @removed;
1414
my @added;
1515
my $in_hunk;
1616

17+
# Some scripts may not realize that SIGPIPE is being ignored when launching the
18+
# pager--for instance scripts written in Python.
19+
$SIG{PIPE} = 'DEFAULT';
20+
1721
while (<>) {
1822
if (!$in_hunk) {
1923
print;

0 commit comments

Comments
 (0)