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 <john@szakmeister.net> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
John Szakmeister committed
Nov 4, 2014 at 15:01 UTC
251e7dad517bd369387c4dedfe77b380f025e0f3
1 file changed
+4
contrib/diff-highlight/diff-highlight
+4
@@ -14,6 +14,10 @@ my @removed;
14
my @added;
15
my $in_hunk;
16
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
+
21
while (<>) {
22
if (!$in_hunk) {
23
print;