!22 【master分支】grep: -s should does not suppress “binary file matches”
From: @yang_zhuang_zhuang Reviewed-by: @xiezhipeng1 Signed-off-by: @xiezhipeng1
This commit is contained in:
commit
2db0d51b03
50
backport-grep-s-does-not-suppress-binary-file-matches.patch
Normal file
50
backport-grep-s-does-not-suppress-binary-file-matches.patch
Normal file
@ -0,0 +1,50 @@
|
||||
From af79b17356f2edeca2908c14d922a24f659d4a96 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
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
|
||||
|
||||
@ -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 <yangzhuangzhuang1@h-partners.com> - 3.7-3
|
||||
- The -s option no longer suppresses "binary file matches" messages
|
||||
|
||||
* Tue Feb 8 2022 yangzhuangzhuang <yangzhuangzhuang1@h-partners.com> - 3.7-2
|
||||
- avoid sticky problem with '-f - -f -'
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user