diff --git a/backport-grep-s-does-not-suppress-binary-file-matches.patch b/backport-grep-s-does-not-suppress-binary-file-matches.patch new file mode 100644 index 0000000000000000000000000000000000000000..596904cd8bf52ce4ea649c6e642a80ed4e53826f --- /dev/null +++ b/backport-grep-s-does-not-suppress-binary-file-matches.patch @@ -0,0 +1,50 @@ +From af79b17356f2edeca2908c14d922a24f659d4a96 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Sat, 20 Nov 2021 22:53:55 -0800 +Subject: [PATCH] =?UTF-8?q?grep:=20-s=20does=20not=20suppress=20?= + =?UTF-8?q?=E2=80=9Cbinary=20file=20matches=E2=80=9D?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +* src/grep.c (grep): Implement this. +* tests/binary-file-matches: Add regression test. +--- + src/grep.c | 2 +- + tests/binary-file-matches | 8 +++++--- + 2 files changed, 11 insertions(+), 4 deletions(-) + +diff --git a/src/grep.c b/src/grep.c +index a55194c..19dff43 100644 +--- a/src/grep.c ++++ b/src/grep.c +@@ -1646,7 +1646,7 @@ grep (int fd, struct stat const *st, bool *ineof) + finish_grep: + done_on_match = done_on_match_0; + out_quiet = out_quiet_0; +- if (binary_files == BINARY_BINARY_FILES && ! (out_quiet | suppress_errors) ++ if (binary_files == BINARY_BINARY_FILES && !out_quiet + && (encoding_error_output + || (0 <= nlines_first_null && nlines_first_null < nlines))) + error (0, 0, _("%s: binary file matches"), input_filename ()); +diff --git a/tests/binary-file-matches b/tests/binary-file-matches +index 7fc4a11..8fea071 100755 +--- a/tests/binary-file-matches ++++ b/tests/binary-file-matches +@@ -14,8 +14,10 @@ fail=0 + echo "grep: (standard input): binary file matches" > exp \ + || framework_failure_ + +-printf 'a\0' | grep a > out 2> err || fail=1 +-compare /dev/null out || fail=1 +-compare exp err || fail=1 ++for option in '' -s; do ++ printf 'a\0' | grep $option a > out 2> err || fail=1 ++ compare /dev/null out || fail=1 ++ compare exp err || fail=1 ++done + + Exit $fail +-- +1.8.3.1 + diff --git a/grep.spec b/grep.spec index 1552b43ba2767e6d9831020bc993dadb1b1d82e4..9c83733a4487698ceb0c028850e911c38b94a2b9 100644 --- a/grep.spec +++ b/grep.spec @@ -1,12 +1,13 @@ Name: grep Version: 3.7 -Release: 2 +Release: 3 Summary: A string search utility License: GPLv3+ URL: http://www.gnu.org/software/grep/ Source0: https://ftp.gnu.org/gnu/grep/grep-%{version}.tar.xz Patch1: backport-grep-avoid-sticky-problem-with-f-f.patch +Patch2: backport-grep-s-does-not-suppress-binary-file-matches.patch BuildRequires: gcc pcre-devel >= 3.9-10 texinfo gettext libsigsegv-devel automake Provides: /bin/egrep /bin/fgrep /bin/grep bundled(gnulib) @@ -46,6 +47,9 @@ make check %changelog +* Fri Mar 18 2022 yangzhuangzhuang - 3.7-3 +- The -s option no longer suppresses "binary file matches" messages + * Tue Feb 8 2022 yangzhuangzhuang - 3.7-2 - avoid sticky problem with '-f - -f -'