From: John Szakmeister Date: Tue, 4 Nov 2014 20:01:12 +0000 (-0500) Subject: diff-highlight: exit when a pipe is broken X-Git-Tag: v2.2.0-rc2~8^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=251e7dad517bd369387c4dedfe77b380f025e0f3;p=thirdparty%2Fgit.git 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 Acked-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/contrib/diff-highlight/diff-highlight b/contrib/diff-highlight/diff-highlight index c4404d49c9..69a652e7b2 100755 --- a/contrib/diff-highlight/diff-highlight +++ b/contrib/diff-highlight/diff-highlight @@ -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;