[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#48680: "zgrep -q" failing with some large files
From: |
David Yoder |
Subject: |
bug#48680: "zgrep -q" failing with some large files |
Date: |
Thu, 27 May 2021 19:34:46 +0000 |
SHORT ANSWER:
Because your results are so different from mine, I tried reproducing on a
personal machine. I tried
* the installed Debian stable gzip 1.9
* downloading the latest gzip 1.10 packaged source
* the git master head
With all three I reproduce your results. And the reason is that zgrep doesn't
support bzip2, so zgrep greps the compressed file and "grep -q fox" doesn't
match, as expected.
This change is in the SuSE 12 installed zgrep and is not in your upstream gzip
release or git repository. I guess it's a patch added by SuSE? Do you know
anything about it?
@@ -198,10 +198,24 @@
for i
do
+ case $i in
+ *.bz2)
+ uncompress=bzip2
+ ;;
+ *.xz)
+ uncompress=xz
+ ;;
+ *.lzma)
+ uncompress=lzma
+ ;;
+ *)
+ uncompress=gzip
+ ;;
+ esac
# Fail if gzip or grep (or sed) fails.
gzip_status=$(
exec 5>&1
- (gzip -cdfq -- "$i" 5>&-; echo $? >&5) 3>&- |
+ ($uncompress -cdfq -- "$i" 5>&-; echo $? >&5) 3>&- |
if test $files_with_matches -eq 1; then
eval "$grep" >/dev/null && { printf '%s\n' "$i" || exit 2; }
elif test $files_without_matches -eq 1; then
DETAILS/ANSWERS:
What platform are you running on? Who built zgrep and gzip on your platform? In
what directories are the zgrep and gzip executables? What is the output of
"gzip --version"?
The platform is SUSE 12 SP5.
This is on machines at work that I don't administer, but zgrep and gzip are
both from a package named gzip-1.10-2.12.x86_64. This looks like the package
from SUSE:
https://scc.suse.com/packages?arch=x86_64&name=SUSE+Linux+Enterprise+Server&package_id=19647018&query=gzip&version=12.5
vl-dyoder-ecdca:~>cat /etc/release
SUSE Linux Enterprise Server 12 (x86_64) 12.5
>rpm -qf /usr/bin/zgrep
gzip-1.10-2.12.x86_64
vl-dyoder-ecdca:~>which zgrep
/usr/bin/zgrep
vl-dyoder-ecdca:~>which gzip
/usr/bin/gzip
vl-dyoder-ecdca:~>gzip --version
gzip 1.10
Copyright (C) 2018 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.
Written by Jean-loup Gailly.
What is the output of the following shell command? unset BASH_ENV; bash -x
./zgrep -q fox synthetic.log.bz2
>unset BASH_ENV; bash -x zgrep -q fox synthetic.log.bz2
+ grep='${GREP-'\''/usr/bin/grep'\''}'
+ version='zgrep (gzip) 1.10
Copyright (C) 2010-2018 Free Software Foundation, Inc.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.
Written by Jean-loup Gailly.'
+ usage='Usage: zgrep [OPTION]... [-e] PATTERN [FILE]...
Look for instances of PATTERN in the input FILEs, using their
uncom
OPTIONs are the same as for '\''grep'\'', except that the following '\''grep'\''
options are not supported: --dereference-recursive (-R), --directories (-d),
--exclude, --exclude-from, --exclude-dir, --include, --null (-Z),
--null-data (-z), and --recursive (-r).
Report bugs to <bug-gzip@gnu.org>.'
+ escape='
s/'\''/'\''\\'\'''\''/g
$s/$/'\''/
'
+ operands=
+ have_pat=0
+ files_with_matches=0
+ files_without_matches=0
+ no_filename=0
+ with_filename=0
+ pattmp=
+ test 3 -ne 0
+ option=-q
+ shift
+ optarg=
+ case $option in
+ case $option in
+ case $option in
+ option=''\''-q'\'''
+ grep='${GREP-'\''/usr/bin/grep'\''} '\''-q'\'''
+ test 2 -ne 0
+ option=fox
+ shift
+ optarg=
+ case $option in
+ case $option in
+ operands=' '\''fox'\'''
+ continue
+ test 1 -ne 0
+ option=synthetic.log.bz2
+ shift
+ optarg=
+ case $option in
+ case $option in
+ operands=' '\''fox'\'' '\''synthetic.log.bz2'\'''
+ continue
+ test 0 -ne 0
+ eval 'set -- '\''fox'\'' '\''synthetic.log.bz2'\'' ${1+"$@"}'
++ set -- fox synthetic.log.bz2
+ test 0 -eq 0
+ case ${1?"missing pattern; try \`$0 --help' for help"} in
+ grep='${GREP-'\''/usr/bin/grep'\''} '\''-q'\'' -- '\''fox'\'''
+ shift
+ test 1 -eq 0
+ exec
+ res=1
+ for i in '"$@"'
+ case $i in
+ uncompress=bzip2
++ exec
++ bzip2 -cdfq -- synthetic.log.bz2
++ test 0 -eq 1
++ test 0 -eq 1
++ test 0 -eq 0
++ test 1 -eq 1
++ eval '${GREP-'\''/usr/bin/grep'\''} '\''-q'\'' -- '\''fox'\'''
+++ /usr/bin/grep -q -- fox
++ echo 141
+ gzip_status=141
+ r=0
+ test 141 -eq 2
+ test 141 -eq 1
+ test 0 -lt 141
+ r=141
+ test 141 -le 1
+ test 1 -lt 141
+ res=141
+ test 126 -le 141
+ break
+ test -n ''
+ test 128 -le 141
++ expr 141 % 128
+ kill -13 3053