Skip to content

Commit

Permalink
diff-highlight: exit when a pipe is broken
Browse files Browse the repository at this point in the history
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 <john@szakmeister.net>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
John Szakmeister authored and Junio C Hamano committed Nov 4, 2014
1 parent eeff891 commit 251e7da
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contrib/diff-highlight/diff-highlight
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ my @removed;
my @added;
my $in_hunk;

# Some scripts may not realize that SIGPIPE is being ignored when launching the
# pager--for instance scripts written in Python.
$SIG{PIPE} = 'DEFAULT';

while (<>) {
if (!$in_hunk) {
print;
Expand Down

0 comments on commit 251e7da

Please sign in to comment.