Fix exit status of xzgrep when grepping binary files.
commitb7ad23fa78646036c0290cd91eada939c9a31526
authorLasse Collin <lasse.collin@tukaani.org>
Wed, 22 Feb 2012 12:02:34 +0000 (22 14:02 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Thu, 24 May 2012 15:52:48 +0000 (24 18:52 +0300)
tree179391c951724e31ae20bd024ae361b75d5acaea
parent4e19fbb04a0035030406482319e264426459eb24
Fix exit status of xzgrep when grepping binary files.

When grepping binary files, grep may exit before it has
read all the input. In this case, gzip -q returns 2 (eating
SIGPIPE), but xz and bzip2 show SIGPIPE as the exit status
(e.g. 141). This causes wrong exit status when grepping
xz- or bzip2-compressed binary files.

The fix checks for the special exit status that indicates SIGPIPE.
It uses kill -l which should be supported everywhere since it
is in both SUSv2 (1997) and POSIX.1-2008.

Thanks to James Buren for the bug report.
src/scripts/xzgrep.in