[Bug 259197] xzgrep should present a message when fed a non-recognised file format

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 29 Apr 2024 09:00:14 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259197

Wolfram Schneider <wosch@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bapt@FreeBSD.org,
                   |                            |kevans@freebsd.org,
                   |                            |wosch@FreeBSD.org
             Status|New                         |Open

--- Comment #1 from Wolfram Schneider <wosch@FreeBSD.org> ---
I think the problem is that the script xzgrep  calls xz(1) with the -f flag by
default.


# create a test file
man tcsh | bzip2 > tcsh.bz2
wc tcsh.bz2
     224    1596   56890 tcsh.bz2

# with the -f flag, xz will return the compressed file if the format is
unknown, and show no warnings
xzcat -f tcsh.bz2 | wc
     224    1596   56890

# xzgrep falls back to binary search in bz2 data
/usr/bin/xzgrep -c . tcsh.bz2 ; echo $?
222
0

# without -f flag
xzcat tcsh.bz2 | grep tcsh; echo $?
xzcat: tcsh.bz2: File format not recognized
1

-- 
You are receiving this mail because:
You are the assignee for the bug.