[Bug 259197] xzgrep should present a message when fed a non-recognised file format
Date: Thu, 08 Jan 2026 12:50:44 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259197
Daniel Tameling <tamelingdaniel@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tamelingdaniel@gmail.com
--- Comment #9 from Daniel Tameling <tamelingdaniel@gmail.com> ---
(In reply to Craig Leres from comment #5)
I don't think it is a good idea to remove the -f flag from the wrapper script.
Quoting the xz man page: "When used with --decompress --stdout and xz cannot
recognize the type of the source file, copy the source file as is to standard
output. This allows xzcat --force to be used like cat(1) for files that have
not been compressed with xz."
So currently you can search normal files simultaneously with xz archives with a
single command. E.g. if one uses xz to compress /var/log/messages one can use
xzgrep harfbuzz /var/log/messages*
to search all files.
Without the flag one would get the warnings for the non-xz files, but they
wouldn't be passed to stdout.
The upstream xzgrep file also uses the -f flag, so changing it in base would
reduce the portability of scripts.
However, upstream has a way to deal with the situation: it invokes other
programs, depending on the file ending:
case $i in
*[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) uncompress="gzip -cdf";;
*[-.]bz2 | *[-.]tbz | *.tbz2) uncompress="bzip2 -cdf";;
*[-.]lzo | *[-.]tzo) uncompress="lzop -cdf";;
*[-.]zst | *[-.]tzst) uncompress="zstd -cdfq";; # zstd needs -q.
*[-.]lz4) uncompress="lz4 -cdf";;
*) uncompress="$xz -cdfqQ";; # -qQ to ignore warnings like unsupp. check.
esac
Something similar could be implemented in our wrapper script if one really
wants to address the issue.
--
You are receiving this mail because:
You are the assignee for the bug.