]> git.ipfire.org Git - thirdparty/xz.git/commit
xzgrep: Use grep -H --label when available (GNU, *BSDs).
authorLasse Collin <lasse.collin@tukaani.org>
Mon, 18 Jul 2022 18:52:31 +0000 (21:52 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Mon, 18 Jul 2022 19:06:10 +0000 (22:06 +0300)
commitbd7b290f3fe4faeceb7d3497ed9bf2e6ed5e7dc5
tree40e44c78d9b1f27a2a7c96e69d29097420f1c325
parentb56729af9f1a596e57aeefd7570d8d7dce5c9f52
xzgrep: Use grep -H --label when available (GNU, *BSDs).

It avoids the use of sed for prefixing filenames to output lines.
Using sed for that is slower and prone to security bugs so now
the sed method is only used as a fallback.

This also fixes an actual bug: When grepping a binary file,
GNU grep nowadays prints its diagnostics to stderr instead of
stdout and thus the sed-method for prefixing the filename doesn't
work. So with this commit grepping binary files gives reasonable
output with GNU grep now.

This was inspired by zgrep but the implementation is different.
src/scripts/xzgrep.in