From unknown Sat Aug 16 22:46:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#51860: [PATCH] Reinstate Binary file matches to stdout Resent-From: Duncan Roe Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Mon, 15 Nov 2021 06:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51860 X-GNU-PR-Package: grep X-GNU-PR-Keywords: patch To: 51860@debbugs.gnu.org Cc: Duncan Roe X-Debbugs-Original-To: bug-grep@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16369564566208 (code B ref -1); Mon, 15 Nov 2021 06:08:02 +0000 Received: (at submit) by debbugs.gnu.org; 15 Nov 2021 06:07:36 +0000 Received: from localhost ([127.0.0.1]:52323 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmV9U-0001c2-5P for submit@debbugs.gnu.org; Mon, 15 Nov 2021 01:07:36 -0500 Received: from lists.gnu.org ([209.51.188.17]:39612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmV9S-0001bu-Ov for submit@debbugs.gnu.org; Mon, 15 Nov 2021 01:07:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmV9S-00088Y-Ja for bug-grep@gnu.org; Mon, 15 Nov 2021 01:07:34 -0500 Received: from [2607:f8b0:4864:20::102d] (port=41693 helo=mail-pj1-x102d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmV9P-0000lZ-SQ for bug-grep@gnu.org; Mon, 15 Nov 2021 01:07:34 -0500 Received: by mail-pj1-x102d.google.com with SMTP id gx15-20020a17090b124f00b001a695f3734aso13110897pjb.0 for ; Sun, 14 Nov 2021 22:07:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wqfPZ5mOoPTBmZxM4jCwGvp0g39iEgORAMGhawHlYPc=; b=WTTfR6KdwS1ZYh4DuLuiQ32KauDbHpWJyvKEaAlc9L+Djw3CQeUDtoRVCg1TudMoXm cP6glm29JOD2BVgAFEvyqJYPTAYrJi2K4Isx7E5cbr8z0QZP93vzy3s+Ic9O/oXEulRd fgoRDDmsZb9j5pFPcuIVjSUAijO2RGUCZgQxYea9rKpJHoCE11Z/vM9W19P2ZFVBGjDE G2nIUL29V8CxJdJNMCFj4MErS5l8L05K6yH14qi9Uopn+3fR1IJm5hJrzLP1oJnRg+WC BhFP1d1IPuGImFiD5VoeouUsvtWw1E6Ffn2VAWD4KkO8naTis3mAPlvYoz07vXs2tH6F QBHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=wqfPZ5mOoPTBmZxM4jCwGvp0g39iEgORAMGhawHlYPc=; b=YIVR/xj+9DPPjNMHH+H6moJyCgInUYl+LSCF72A2gVToCNsSr/xAS93JrTsYYcKQMz k9AE7uOWO9J8cSsrgKGrGl+GB6uVhyuW/Vswn7Irwt01EeS+ZydG6o4SyMpXafQOb5kx bWzbDYJilTZ6Cc5jyhx14oeuwmchMGtJC36L0NQH0XHVGSOeKokczwDRLg/yjBFkqAB2 MhKdNf+IC06kfZxfOPwDw0HoYccSUD+3kpI+G8PaAzEGm4qo5XAsGda+6PJDGdi86wOV jx7Vg2TxM+mRPgISrxYsvJDyMARKeAy3ETRecZHI5XDxCm0hJDxiZcM2DTZtwSvsztAI aW/g== X-Gm-Message-State: AOAM533ZJjE/PJu38Ys5VuHFEBoEheAVK8ZaZtO/Nr1jehrqfpVWE10B 7xGY0sT5KKaL/LQhMOyCCzDkCy4m8wk= X-Google-Smtp-Source: ABdhPJwm1Hcde95z4SDVjfp1d/2e74wqDrdwgbS08ptk7pxq7Wq1KssN78i2Ba2twLiLbB3nvvAxUw== X-Received: by 2002:a17:90b:1d81:: with SMTP id pf1mr24956043pjb.134.1636956449350; Sun, 14 Nov 2021 22:07:29 -0800 (PST) Received: from slk1.local.net (n110-23-108-30.sun3.vic.optusnet.com.au. [110.23.108.30]) by smtp.gmail.com with ESMTPSA id w5sm14525668pfu.219.2021.11.14.22.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Nov 2021 22:07:28 -0800 (PST) From: Duncan Roe Date: Mon, 15 Nov 2021 17:06:29 +1100 Message-Id: <20211115060629.19131-1-duncan_roe@optusnet.com.au> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=duncan.roe2@gmail.com; helo=mail-pj1-x102d.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) Revert commit 271793f0. * NEWS: Mention this. * doc/grep.texi: remove 1 line added in 271793f0. * src/grep.c (grep): Send traditional "Binary file FOO matches" to stdout again. * tests/surrogate-pair: test for traditional behaviour (test updated since 271793f0). * tests/null-byte: Reverted (non-conflicting changes since 271793f0). * tests/encoding-error, tests/invalid-multibyte-infloop: * tests/pcre-count, tests/symlink, tests/unibyte-binary: Reverted (unchanged since 271793f0). * tests/binary-file-matches: test for traditional behavior (new test). Signed-off-by: Duncan Roe --- NEWS | 6 ++++++ doc/grep.texi | 3 +-- src/grep.c | 8 ++++++-- tests/binary-file-matches | 6 +++--- tests/encoding-error | 5 +++-- tests/invalid-multibyte-infloop | 4 +++- tests/null-byte | 2 +- tests/pcre-count | 5 +++-- tests/surrogate-pair | 12 ++++++++---- tests/symlink | 6 +++++- tests/unibyte-binary | 2 +- 11 files changed, 40 insertions(+), 19 deletions(-) diff --git a/NEWS b/NEWS index 2f63071..0173187 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,12 @@ GNU grep NEWS -*- outline -*- ** Changes in behavior + The message that a binary file matches is again sent to standard output + with the wording as it was before release 3.5. The -I option is available + to suppress this message if so desired. The behavior in grep 3.5 + through 3.7 prevented a user seeing binary matches when using + grep -s to suppress error messages. + The -P option is now based on PCRE2 instead of the older PCRE, thanks to code contributed by Carlo Arenas. diff --git a/doc/grep.texi b/doc/grep.texi index c3c4bbf..2482fa0 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -1819,8 +1819,7 @@ to output lines even from files that appear to be binary, use the @option{-a} or @samp{--binary-files=text} option. To eliminate the ``Binary file matches'' messages, use the @option{-I} or -@samp{--binary-files=without-match} option, -or the @option{-s} or @option{--no-messages} option. +@samp{--binary-files=without-match} option. @item Why doesn't @samp{grep -lv} print non-matching file names? diff --git a/src/grep.c b/src/grep.c index a55194c..0e60023 100644 --- a/src/grep.c +++ b/src/grep.c @@ -1646,10 +1646,14 @@ 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 ()); + { + printf_errno (_("Binary file %s matches\n"), input_filename ()); + if (line_buffered) + fflush_errno (); + } return nlines; } diff --git a/tests/binary-file-matches b/tests/binary-file-matches index 7fc4a11..dc4c3e7 100755 --- a/tests/binary-file-matches +++ b/tests/binary-file-matches @@ -11,11 +11,11 @@ fail=0 -echo "grep: (standard input): binary file matches" > exp \ +echo "Binary file (standard input) 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 +compare /dev/null err || fail=1 +compare exp out || fail=1 Exit $fail diff --git a/tests/encoding-error b/tests/encoding-error index 2ec71c9..9fb496c 100755 --- a/tests/encoding-error +++ b/tests/encoding-error @@ -25,7 +25,8 @@ grep '^A' in >out || fail=1 compare a out || fail=1 grep '^P' in >out || fail=1 -compare /dev/null out || fail=1 +printf 'Binary file in matches\n' >exp || framework_failure_ +compare exp out || fail=1 grep -I '^P' in >out 2>err || fail=1 compare /dev/null out || fail=1 @@ -38,7 +39,7 @@ returns_ 1 grep '^X' in >out || fail=1 compare /dev/null out || fail=1 grep . in >out || fail=1 -cat a j >exp || framework_failure_ +(cat a j && printf 'Binary file in matches\n') >exp || framework_failure_ compare exp out || fail=1 grep -I . in >out 2>err || fail=1 diff --git a/tests/invalid-multibyte-infloop b/tests/invalid-multibyte-infloop index b4ad14b..5b3bdfc 100755 --- a/tests/invalid-multibyte-infloop +++ b/tests/invalid-multibyte-infloop @@ -24,10 +24,12 @@ else test $status -eq 2 fi || fail=1 +echo 'Binary file input matches' >binary-file-matches + LC_ALL=en_US.UTF-8 timeout 10 grep -F $(encode A) input > out status=$? if test $status -eq 0; then - compare /dev/null out + compare binary-file-matches out elif test $status -eq 1; then compare_dev_null_ /dev/null out else diff --git a/tests/null-byte b/tests/null-byte index d86c249..9354aaf 100755 --- a/tests/null-byte +++ b/tests/null-byte @@ -56,7 +56,7 @@ echo xxx >exp || framework_failure_ grep xxx in >out || fail=1 compare exp out || fail=1 -printf 'xxx\n' > exp || framework_failure_ +printf '%s\n' xxx 'Binary file in matches' > exp || framework_failure_ grep -E 'xxx|z' in >out || fail=1 compare exp out || fail=1 diff --git a/tests/pcre-count b/tests/pcre-count index 9eda54b..656780e 100755 --- a/tests/pcre-count +++ b/tests/pcre-count @@ -17,9 +17,10 @@ printf 'a\n%032768d\nb\0\n%032768d\na\n' 0 0 > in || framework_failure_ # grep will discover that the input is a binary file sooner if the # page size is larger, so allow for either possible output. -printf 'a\n' >exp1a || framework_failure_ +printf 'a\nBinary file in matches\n' >exp1a || framework_failure_ +printf 'Binary file in matches\n' >exp1b || framework_failure_ LC_ALL=C grep -P 'a' in >out || fail=1 -compare exp1a out || compare /dev/null out || fail=1 +compare exp1a out || compare exp1b out || fail=1 printf '2\n' >exp2 || framework_failure_ LC_ALL=C grep -Pc 'a' in >out || fail=1 diff --git a/tests/surrogate-pair b/tests/surrogate-pair index a91fa36..7f8373a 100755 --- a/tests/surrogate-pair +++ b/tests/surrogate-pair @@ -26,6 +26,10 @@ fail=0 s_pair=$(printf '\360\220\220\205') printf '%s\n' "$s_pair" > in || framework_failure_ +# On platforms where wchar_t is only 16 bits, wchar_t cannot represent +# the character encoded in 'in', so accept that behavior too. +printf 'Binary file in matches\n' > out16 || framework_failure_ + LC_ALL=en_US.UTF-8 export LC_ALL @@ -41,12 +45,12 @@ grep . in > out 2> err || fail=1 # On platforms where wchar_t is only 16 bits, wchar_t cannot represent # the character encoded in 'in'. -# On such old systems the above prints nothing on stdout and a diagnostic -# on stderr. In that case, return early; otherwise, the following tests +# On such old systems the above prints diagnostic on stdout. +# In that case, return early; otherwise, the following tests # would all fail. io_pair=$(cat out):$(cat err) case $io_pair in - :'grep: in: binary file matches') Exit $fail;; + 'Binary file in matches:') Exit $fail;; $s_pair:) ;; *) fail_ "unexpected output: $io_pair"; fail=1;; esac @@ -54,7 +58,7 @@ esac # Also test whether a surrogate-pair in the search string works. for opt in '' -i -E -F -iE -iF; do grep --file=in $opt in > out 2>&1 || fail=1 - compare out in || fail=1 + compare out in || compare out out16 || fail=1 done Exit $fail diff --git a/tests/symlink b/tests/symlink index b580ce7..427dfed 100755 --- a/tests/symlink +++ b/tests/symlink @@ -58,7 +58,11 @@ do printf "$exp" >exp || framework_failure_ - LC_ALL=C sort grepout >out || fail=1 + LC_ALL=C sort grepout >out-t || fail=1 + + # Ignore "Binary file d matches" on systems for which + # reading from a directory actually succeeds. + grep -v Binary out-t > out; case $? in 0|1) ;; *) fail=1;; esac compare exp out || fail=1 done diff --git a/tests/unibyte-binary b/tests/unibyte-binary index f76276f..7e8f2aa 100755 --- a/tests/unibyte-binary +++ b/tests/unibyte-binary @@ -22,7 +22,7 @@ require_unibyte_locale fail=0 printf 'a\n\200\nb\n' >in || framework_failure_ -printf 'a\n' >exp || framework_failure_ +printf 'a\nBinary file in matches\n' >exp || framework_failure_ grep . in >out || fail=1 # In some unibyte locales, \200 is an encoding error; -- 2.33.1 From unknown Sat Aug 16 22:46:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#51860: [PATCH] Reinstate Binary file matches to stdout Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Tue, 16 Nov 2021 18:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51860 X-GNU-PR-Package: grep X-GNU-PR-Keywords: patch To: Duncan Roe Cc: 51860@debbugs.gnu.org Received: via spool by 51860-submit@debbugs.gnu.org id=B51860.16370861237811 (code B ref 51860); Tue, 16 Nov 2021 18:09:01 +0000 Received: (at 51860) by debbugs.gnu.org; 16 Nov 2021 18:08:43 +0000 Received: from localhost ([127.0.0.1]:59090 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mn2ss-00021v-Pk for submit@debbugs.gnu.org; Tue, 16 Nov 2021 13:08:43 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:37852) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mn2sq-00021V-R4 for 51860@debbugs.gnu.org; Tue, 16 Nov 2021 13:08:41 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BFFB21600EF; Tue, 16 Nov 2021 10:08:34 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id YSygtUJmAcmn; Tue, 16 Nov 2021 10:08:34 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EE4261600CE; Tue, 16 Nov 2021 10:08:33 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id e6TyXehZHt1P; Tue, 16 Nov 2021 10:08:33 -0800 (PST) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C702E1600AE; Tue, 16 Nov 2021 10:08:33 -0800 (PST) Message-ID: Date: Tue, 16 Nov 2021 10:08:33 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Content-Language: en-US References: <20211115060629.19131-1-duncan_roe@optusnet.com.au> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <20211115060629.19131-1-duncan_roe@optusnet.com.au> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.4 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) The change that you're objecting to was put in to fix issues with the way 'grep' used to behave[1][2]. Could you describe what problems the change caused for you? [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29668 [2] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=33552 From unknown Sat Aug 16 22:46:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#51860: [PATCH] Reinstate Binary file matches to stdout Resent-From: Duncan Roe Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Fri, 19 Nov 2021 01:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51860 X-GNU-PR-Package: grep X-GNU-PR-Keywords: patch To: Paul Eggert Cc: 51860@debbugs.gnu.org Received: via spool by 51860-submit@debbugs.gnu.org id=B51860.163728476519999 (code B ref 51860); Fri, 19 Nov 2021 01:20:01 +0000 Received: (at 51860) by debbugs.gnu.org; 19 Nov 2021 01:19:25 +0000 Received: from localhost ([127.0.0.1]:37460 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mnsYm-0005CV-Qb for submit@debbugs.gnu.org; Thu, 18 Nov 2021 20:19:25 -0500 Received: from mail-pg1-f181.google.com ([209.85.215.181]:34393) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mnsYk-0005CI-NJ for 51860@debbugs.gnu.org; Thu, 18 Nov 2021 20:19:23 -0500 Received: by mail-pg1-f181.google.com with SMTP id 200so7151363pga.1 for <51860@debbugs.gnu.org>; Thu, 18 Nov 2021 17:19:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DJgdYYwEDQa4EsEOQ+jnI50F9/+j3LE/RghNd/lZfac=; b=SCqZlI3UI2QJLXiK/fJ/oDpwggxiVNk0gy/N5lh9NPYfTCb+v/Riuoup7jxSRC159j 3KOZLz3PQGspDWUtMCs7yOihRDdtJ6UkqX5phhaRVMgoLAuzUvg16jOi3rKkx/O19IEx ae0mj8QbAlGIDmXoqsTfUi8jTyJguye+E5TzysZYx6l+HpGd4seHQ0VFGDWLumiVAp+Q ewX5PWEf4jn/V10NSNkoP7psV6ZhV+NAKv6sBqBnpnN4wDhDAHDHiljXCL8KlUygNyI2 LYioNPG7ToYtOZRQHUGH5+dvf3epX8YrtrRRofwXXeIZH9fvP59tAsARCa8QayxHw74c AkKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=DJgdYYwEDQa4EsEOQ+jnI50F9/+j3LE/RghNd/lZfac=; b=DdYzV4dBMbfhhbmP6kR4vvwGXAzfZrCU2qhrJFDQoICAUzEw5/1Oz/ZAHU7LwYWM8G Gvu5khp+ve6KwUblp+Jq3DY7cXojSEgxfjpAK+jqRb784ArQaeLghxVQ7rCM2PvyKbL2 1y9vTqjeODNFqamqEvKkcroVbl0iDND6LmI3XHkD+j/hdeowy8le6Rn4CLa5smEMl/mw QY2OJrcCx9OXXnxojPH5XT4Q2aMX9DV44wvO4CpMZX0W21fjUnfrlq4EU3RcfFS4eV+R 6wRZPlE1Z9Uo8gt8mUmEKztxjNSgDzYxLtS1VQMTfWDQpuLv2Jm/GQI7OwQ/TWorzNdv H9aw== X-Gm-Message-State: AOAM530XqAHJYcr/OG/6cnxKEtNMzkjF+hxjhlyg6+eOC8Wf/4tpBKHA Jv7+15i9cuE/28bhZpBZHHA= X-Google-Smtp-Source: ABdhPJxj5AdbTSNalkm/hzzlfYj0FsrIlkeF/CH1tGvph5751wrNh7uvwkYadbrjRHZL2AS+ZU72ag== X-Received: by 2002:a63:4618:: with SMTP id t24mr14321077pga.430.1637284756833; Thu, 18 Nov 2021 17:19:16 -0800 (PST) Received: from slk1.local.net (n110-23-108-30.sun3.vic.optusnet.com.au. [110.23.108.30]) by smtp.gmail.com with ESMTPSA id m6sm629901pgc.17.2021.11.18.17.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 17:19:16 -0800 (PST) From: Duncan Roe X-Google-Original-From: Duncan Roe Date: Fri, 19 Nov 2021 12:19:12 +1100 Message-ID: References: <20211115060629.19131-1-duncan_roe@optusnet.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) Bug#33552 refers to -I not working which was already fixed by c3245083 before 271793f0. (c3245083 shows up before 271793f0 in `git log` although commit times are in reverse order). With regard to Bug#29668: they can use `grep -s -I`. Their real problem was that `-I` didn't work. Now to the problems the change caused for me: Background: I have a collection[1] of find/grep commands all designed to be piped into `less`. They all use `grep --line-buffered` (since `less` to the tty will be line buffered), grep -s (to avoid stderr output which would mess up `less`) and `sed -u` (approximately line buffered as well). My distro is Slackware and most of the time I use the 14.2 bare metal system which has grep 2.25. So I didn't see the altered grep behaviour until I had a Slackware Current (15.0 Beta) VM. On the 15.0 VM I was searching in a build directory for why a program was complaining about a shared library it had no business using. So I searched via the `yfl` symlink (which "always" finds everything) and found ... nothing. Not even a binary match in the executable. I spent some time reviewing the `sfl` script before I twigged it was changed grep behaviour. (BTW the executable was the only match. I had left LIBS in the environment from something else I was working on). I could go on, but hope I have said enough. [1] https://github.com/duncan-roe/command_line_tools/blob/master/bin/sfl There are 21 symlinks to this script, for a total of 22 commands. From unknown Sat Aug 16 22:46:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#51860: [PATCH] Reinstate Binary file matches to stdout Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Fri, 19 Nov 2021 09:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51860 X-GNU-PR-Package: grep X-GNU-PR-Keywords: patch To: Duncan Roe Cc: 51860@debbugs.gnu.org Received: via spool by 51860-submit@debbugs.gnu.org id=B51860.163731375731598 (code B ref 51860); Fri, 19 Nov 2021 09:23:01 +0000 Received: (at 51860) by debbugs.gnu.org; 19 Nov 2021 09:22:37 +0000 Received: from localhost ([127.0.0.1]:38016 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mo06O-0008DZ-9s for submit@debbugs.gnu.org; Fri, 19 Nov 2021 04:22:36 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:32946) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mo06J-0008DA-3B for 51860@debbugs.gnu.org; Fri, 19 Nov 2021 04:22:35 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BB686160051; Fri, 19 Nov 2021 01:22:24 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id CqUYGDUrThRV; Fri, 19 Nov 2021 01:22:23 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D24D5160083; Fri, 19 Nov 2021 01:22:23 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id dma54HjMa8F7; Fri, 19 Nov 2021 01:22:23 -0800 (PST) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id AB662160051; Fri, 19 Nov 2021 01:22:23 -0800 (PST) Message-ID: <1dd531bd-b711-5820-531d-62c92e0aea0f@cs.ucla.edu> Date: Fri, 19 Nov 2021 01:22:23 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Content-Language: en-US References: <20211115060629.19131-1-duncan_roe@optusnet.com.au> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.4 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) On 11/18/21 17:19, Duncan Roe wrote: > With regard to Bug#29668: they can use `grep -s -I`. > Their real problem was that `-I` didn't work. The problem I was referring to was described here: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29668#17 This is the problem of what an ordinary 'grep' user would expect with just 'grep PATTERN FILE | wc', without any options. When the "Binary file FILE matches" message is sent to 'wc' its information is lost to the user. When the message is sent to stderr, the user sees it and has a helpful indication that the usage is problematic. Using 'grep -s -I' wouldn't have helped with this problem. > They all use `grep --line-buffered` (since `less` to the tty > will be line buffered), grep -s (to avoid stderr output which would mess up > `less`) You can use "grep PATTERN FILE 2>&1 | less". This shouldn't mess up 'less'. From unknown Sat Aug 16 22:46:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#51860: [PATCH] Reinstate Binary file matches to stdout Resent-From: Duncan Roe Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Sun, 21 Nov 2021 01:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51860 X-GNU-PR-Package: grep X-GNU-PR-Keywords: patch To: Paul Eggert Cc: 51860@debbugs.gnu.org Received: via spool by 51860-submit@debbugs.gnu.org id=B51860.16374587485742 (code B ref 51860); Sun, 21 Nov 2021 01:40:02 +0000 Received: (at 51860) by debbugs.gnu.org; 21 Nov 2021 01:39:08 +0000 Received: from localhost ([127.0.0.1]:43873 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mobox-0001UY-JD for submit@debbugs.gnu.org; Sat, 20 Nov 2021 20:39:07 -0500 Received: from mail-pf1-f169.google.com ([209.85.210.169]:37631) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mobos-0001Tt-5P for 51860@debbugs.gnu.org; Sat, 20 Nov 2021 20:39:05 -0500 Received: by mail-pf1-f169.google.com with SMTP id 8so12627171pfo.4 for <51860@debbugs.gnu.org>; Sat, 20 Nov 2021 17:39:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=0aO9LaXwcBbNI84Vs0kfd544NhEcbxy14/Gt6XGfJSU=; b=k8WwSvObIq19BVTSuE8c8KMMLi/G3d3KWcMk5TSQrnM9eaAQX1CryjUqGieS/p3bKc wSujXvxko7YweUycOJBvh/IgXmRre3OhRwCx0BkyQ8bvJBGamkZBdN7HQpsQ8s2XJVw2 tnO0FuYsG1ggoghUzRelovHvSIugKkYVZm7pgLCy8JADvliCxtnw6Qe0psLeV7/OXltx 68CHh/8K9XG7ZkbXWm/vUPN6HbR0dH1aBZ9mT8zwU+SE7txnHvBleWw8navJGQP6NUTD c9UHGKbN4IsM058f+Evs/yBv/s1GTTyljROJh2HAk144X59fuiK2K0Y1XC1AheJ1ZqaP ygVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=0aO9LaXwcBbNI84Vs0kfd544NhEcbxy14/Gt6XGfJSU=; b=xcVadIsLl4nON71GQgnB2fNxz/TTBz1xoiM7GoVGddtiDPiR7px12FqR1EhMNSTA1G TiFAXMH4+sJv0gZZ/yFYtCaQh+v4kTBssfqgoTfYkL4Fxq86hl0kJgubqWHaIBaYAEqF uS/sAGT95nZrxV6FbaZRlWNessZ+q2W/AWLjSuIfma1cmqQVItrtpFedRKbwINGJTT2/ 7ZzDT1UXKugxWdfMQ11yh+4uuHzKtQ1CwiM1RslVRgtJbUBMBz0kpKYAHs5Bzh0NZA6d DJfeofSvsBSu7pXzPCs+Rqj6C6PHNuvW4ar02DBwfQ8z9U7JVLV8IFGPJarjVFaS49DH gQ4g== X-Gm-Message-State: AOAM530NRMV7tkabVCz3kLq4RmTyV595uJ2Od5WkiZTRyFJjOpMET7rD o2FnV6PcVwKm/G5/Qu1C0bmB1lMTvGA= X-Google-Smtp-Source: ABdhPJyHvW2W4xuNRnXrfjWg8oY0QG2KkS6Ug8WMFJrtMsbvC6T4Itoh/vEUgele38cslPMm8dDPOg== X-Received: by 2002:a63:171a:: with SMTP id x26mr25773143pgl.323.1637458736162; Sat, 20 Nov 2021 17:38:56 -0800 (PST) Received: from slk1.local.net (n110-23-108-30.sun3.vic.optusnet.com.au. [110.23.108.30]) by smtp.gmail.com with ESMTPSA id g22sm4168858pfj.29.2021.11.20.17.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Nov 2021 17:38:55 -0800 (PST) From: Duncan Roe X-Google-Original-From: Duncan Roe Date: Sun, 21 Nov 2021 12:38:51 +1100 Message-ID: References: <20211115060629.19131-1-duncan_roe@optusnet.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) On Fri, Nov 19, 2021 at 01:22:23AM -0800, Paul Eggert wrote: > On 11/18/21 17:19, Duncan Roe wrote: > > With regard to Bug#29668: they can use `grep -s -I`. > > Their real problem was that `-I` didn't work. > > The problem I was referring to was described here: > > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29668#17 > > This is the problem of what an ordinary 'grep' user would expect with just > 'grep PATTERN FILE | wc', without any options. "ordinary 'grep' user"? Like in "grep user who doesn't RTFM"? This was *documented* *behaviour*. And it still is documented behaviour, except now grep doesn't abide by its documentation(*). > When the "Binary file FILE > matches" message is sent to 'wc' its information is lost to the user. When > the message is sent to stderr, the user sees it and has a helpful indication > that the usage is problematic. That's a nice idea, but I suggest it was a mis-step to unilaterally change grep to achieve it. A new (GNU extension) option to send binary file matches to stderr would have been better IMHO. I'd further suggest biaary matches output to stderr by the new option be not affected by the setting of `-s`, only by `-I`. This reinstates orthogonality of -s and -I which 271793f0 broke. Documenting the new option would be easy. On which subject: Quoting commit 271793f0 > Adjust tests to match new behavior. In all cases this > simplifies the tests, which is a good sign. A good sign? Maybe. I have found that a much better sign is "How easy is updating the documentation to reflect this change?". If it's awkward, perhaps the change was a bad idea. The man page is not yet updated to reflect the new `-s` behaviour. Nor is the texi(*). For option `-s` the man page says: > Suppress error messages about nonexistent or unreadable files. Binary file matches are neither of the above. You need to update the man page to explain that binary file matches are now treated as errors. Personally, I'd find that embasassing. > > Using 'grep -s -I' wouldn't have helped with this problem. Why did you offer an updated `-s` as a solution then? > > > > They all use `grep --line-buffered` (since `less` to the tty > > will be line buffered), grep -s (to avoid stderr output which would mess up > > `less`) > > You can use "grep PATTERN FILE 2>&1 | less". This shouldn't mess up 'less'. As it happens, I find I can. I don't need `grep -s` inside `sfl` - it's a holdover from before when I first wrote `sfl` last century. Back then, I was using `grep -swn` to hide errors about unreadable directories. Since you have provided me with a workaround, I have no further interset in this bug. I still think the 271793f0 functionality change was wrong and could and should be improved on. But that's up to you. (*) I'm discounting the 1-liner in the FAQ as wholly inadequate. From unknown Sat Aug 16 22:46:50 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Duncan Roe Subject: bug#51860: closed (Re: bug#51860: [PATCH] Reinstate Binary file matches to stdout) Message-ID: References: <20211115060629.19131-1-duncan_roe@optusnet.com.au> X-Gnu-PR-Message: they-closed 51860 X-Gnu-PR-Package: grep X-Gnu-PR-Keywords: patch Reply-To: 51860@debbugs.gnu.org Date: Sun, 21 Nov 2021 07:00:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1637478002-27633-1" This is a multi-part message in MIME format... ------------=_1637478002-27633-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #51860: [PATCH] Reinstate Binary file matches to stdout which was filed against the grep package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 51860@debbugs.gnu.org. --=20 51860: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D51860 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1637478002-27633-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 51860-done) by debbugs.gnu.org; 21 Nov 2021 06:59:55 +0000 Received: from localhost ([127.0.0.1]:44042 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mogpP-0007B3-3n for submit@debbugs.gnu.org; Sun, 21 Nov 2021 01:59:55 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:59588) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mogpN-0007An-B2 for 51860-done@debbugs.gnu.org; Sun, 21 Nov 2021 01:59:54 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3FC1E1600C5; Sat, 20 Nov 2021 22:59:47 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 3E6QAOpVi311; Sat, 20 Nov 2021 22:59:45 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E8ADF160112; Sat, 20 Nov 2021 22:59:44 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Zo7SegGmx6Ta; Sat, 20 Nov 2021 22:59:44 -0800 (PST) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 7FD141600C5; Sat, 20 Nov 2021 22:59:44 -0800 (PST) Content-Type: multipart/mixed; boundary="------------qE14K4VDscsvfe7BrPdpQtia" Message-ID: Date: Sat, 20 Nov 2021 22:59:43 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Content-Language: en-US To: Duncan Roe References: <20211115060629.19131-1-duncan_roe@optusnet.com.au> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: bug#51860: [PATCH] Reinstate Binary file matches to stdout In-Reply-To: X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 51860-done Cc: 51860-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) This is a multi-part message in MIME format. --------------qE14K4VDscsvfe7BrPdpQtia Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/20/21 17:38, Duncan Roe wrote: > This was *documented* *behaviour*. No, it wasn't documented whether the "Binary file matches" message is sent to stdout or to stderr. But now that you mention it, this should be documented. First patch attached, and installed into the development version. > I'd further suggest biaary matches output to stderr by the new option be not > affected by the setting of `-s`, only by `-I`. This reinstates orthogonality of > -s and -I which 271793f0 broke. Hmm, you have a point that -s is documented to "Suppress error messages about nonexistent or unreadable files" and it's plausible to say that the "binary file matches" diagnostic, although it is about a binary file that 'grep' has some trouble reading, is not about a file that is "unreadable". So, let's fix the code to match that part of the spec again. Second patch attached and installed. > Since you have provided me with a workaround, I have no further interset in this > bug. OK, closing the bug report. Thanks for reporting the issues. --------------qE14K4VDscsvfe7BrPdpQtia Content-Type: text/x-patch; charset=UTF-8; name="0001-doc-binary-file-matches-stderr-Bug-51860.patch" Content-Disposition: attachment; filename="0001-doc-binary-file-matches-stderr-Bug-51860.patch" Content-Transfer-Encoding: base64 RnJvbSA1Njc2MmJmZGE1NjdhYzJmOTZhYjJmODhlODExN2I1NjAyYmNjZGRiIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1 PgpEYXRlOiBTYXQsIDIwIE5vdiAyMDIxIDIyOjUxOjI2IC0wODAwClN1YmplY3Q6IFtQQVRD SCAxLzJdIGRvYzogImJpbmFyeSBmaWxlIG1hdGNoZXMiIC0+IHN0ZGVyciBbQnVnIzUxODYw XQoKLS0tCiBkb2MvZ3JlcC5pbi4xIHwgMiArLQogZG9jL2dyZXAudGV4aSB8IDIgKy0KIDIg ZmlsZXMgY2hhbmdlZCwgMiBpbnNlcnRpb25zKCspLCAyIGRlbGV0aW9ucygtKQoKZGlmZiAt LWdpdCBhL2RvYy9ncmVwLmluLjEgYi9kb2MvZ3JlcC5pbi4xCmluZGV4IDIwOGNiNzYuLjEy M2I4ZDYgMTAwNjQ0Ci0tLSBhL2RvYy9ncmVwLmluLjEKKysrIGIvZG9jL2dyZXAuaW4uMQpA QCAtNTIwLDcgKzUyMCw3IEBAIGFuZCBzdXBwcmVzc2VzIG91dHB1dCBsaW5lcyB0aGF0IGNv bnRhaW4gaW1wcm9wZXJseSBlbmNvZGVkIGRhdGEuCiBXaGVuIHNvbWUgb3V0cHV0IGlzIHN1 cHByZXNzZWQsCiAuQiBncmVwCiBmb2xsb3dzIGFueSBvdXRwdXQKLXdpdGggYSBvbmUtbGlu ZSBtZXNzYWdlIHNheWluZyB0aGF0IGEgYmluYXJ5IGZpbGUgbWF0Y2hlcy4KK3dpdGggYSBt ZXNzYWdlIHRvIHN0YW5kYXJkIGVycm9yIHNheWluZyB0aGF0IGEgYmluYXJ5IGZpbGUgbWF0 Y2hlcy4KIC5JUAogSWYKIC5JIFRZUEUKZGlmZiAtLWdpdCBhL2RvYy9ncmVwLnRleGkgYi9k b2MvZ3JlcC50ZXhpCmluZGV4IGMzYzRiYmYuLmIxZGE1Y2IgMTAwNjQ0Ci0tLSBhL2RvYy9n cmVwLnRleGkKKysrIGIvZG9jL2dyZXAudGV4aQpAQCAtNjE1LDcgKzYxNSw3IEBAIEJ5IGRl ZmF1bHQsIEB2YXJ7dHlwZX0gaXMgQHNhbXB7YmluYXJ5fSwgYW5kIEBjb21tYW5ke2dyZXB9 CiBzdXBwcmVzc2VzIG91dHB1dCBhZnRlciBudWxsIGlucHV0IGJpbmFyeSBkYXRhIGlzIGRp c2NvdmVyZWQsCiBhbmQgc3VwcHJlc3NlcyBvdXRwdXQgbGluZXMgdGhhdCBjb250YWluIGlt cHJvcGVybHkgZW5jb2RlZCBkYXRhLgogV2hlbiBzb21lIG91dHB1dCBpcyBzdXBwcmVzc2Vk LCBAY29tbWFuZHtncmVwfSBmb2xsb3dzIGFueSBvdXRwdXQKLXdpdGggYSBvbmUtbGluZSBt ZXNzYWdlIHNheWluZyB0aGF0IGEgYmluYXJ5IGZpbGUgbWF0Y2hlcy4KK3dpdGggYSBtZXNz YWdlIHRvIHN0YW5kYXJkIGVycm9yIHNheWluZyB0aGF0IGEgYmluYXJ5IGZpbGUgbWF0Y2hl cy4KIAogSWYgQHZhcnt0eXBlfSBpcyBAc2FtcHt3aXRob3V0LW1hdGNofSwKIHdoZW4gQGNv bW1hbmR7Z3JlcH0gZGlzY292ZXJzIG51bGwgaW5wdXQgYmluYXJ5IGRhdGEKLS0gCjIuMzIu MAoK --------------qE14K4VDscsvfe7BrPdpQtia Content-Type: text/x-patch; charset=UTF-8; name="0002-grep-s-does-not-suppress-binary-file-matches.patch" Content-Disposition: attachment; filename="0002-grep-s-does-not-suppress-binary-file-matches.patch" Content-Transfer-Encoding: base64 RnJvbSBhZjc5YjE3MzU2ZjJlZGVjYTI5MDhjMTRkOTIyYTI0ZjY1OWQ0YTk2IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1 PgpEYXRlOiBTYXQsIDIwIE5vdiAyMDIxIDIyOjUzOjU1IC0wODAwClN1YmplY3Q6IFtQQVRD SCAyLzJdID0/VVRGLTg/cT9ncmVwOj0yMC1zPTIwZG9lcz0yMG5vdD0yMHN1cHByZXNzPTIw Pz0KID0/VVRGLTg/cT89RTI9ODA9OUNiaW5hcnk9MjBmaWxlPTIwbWF0Y2hlcz1FMj04MD05 RD89Ck1JTUUtVmVyc2lvbjogMS4wCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNl dD1VVEYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA4Yml0CgoqIHNyYy9ncmVwLmMg KGdyZXApOiBJbXBsZW1lbnQgdGhpcy4KKiB0ZXN0cy9iaW5hcnktZmlsZS1tYXRjaGVzOiBB ZGQgcmVncmVzc2lvbiB0ZXN0LgotLS0KIE5FV1MgICAgICAgICAgICAgICAgICAgICAgfCA1 ICsrKysrCiBzcmMvZ3JlcC5jICAgICAgICAgICAgICAgIHwgMiArLQogdGVzdHMvYmluYXJ5 LWZpbGUtbWF0Y2hlcyB8IDggKysrKystLS0KIDMgZmlsZXMgY2hhbmdlZCwgMTEgaW5zZXJ0 aW9ucygrKSwgNCBkZWxldGlvbnMoLSkKCmRpZmYgLS1naXQgYS9ORVdTIGIvTkVXUwppbmRl eCAyZjYzMDcxLi41MDE1NTgwIDEwMDY0NAotLS0gYS9ORVdTCisrKyBiL05FV1MKQEAgLTEx LDYgKzExLDExIEBAIEdOVSBncmVwIE5FV1MgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAtKi0gb3V0bGluZSAtKi0KICAgcmVsZWFzZSAyLjUuMyAoMjAwNyksIG5vdyB3 YXJuIHRoYXQgdGhleSBhcmUgb2Jzb2xlc2NlbnQgYW5kIHNob3VsZAogICBiZSByZXBsYWNl ZCBieSBncmVwIC1FIGFuZCBncmVwIC1GLgogCisqKiBCdWcgZml4ZXMKKworICBUaGUgLXMg b3B0aW9uIG5vIGxvbmdlciBzdXBwcmVzc2VzICJiaW5hcnkgZmlsZSBtYXRjaGVzIiBtZXNz YWdlcy4KKyAgW0J1ZyM1MTg2MCBpbnRyb2R1Y2VkIGluIGdyZXAgMy41XQorCiAKICogTm90 ZXdvcnRoeSBjaGFuZ2VzIGluIHJlbGVhc2UgMy43ICgyMDIxLTA4LTE0KSBbc3RhYmxlXQog CmRpZmYgLS1naXQgYS9zcmMvZ3JlcC5jIGIvc3JjL2dyZXAuYwppbmRleCBhNTUxOTRjLi4x OWRmZjQzIDEwMDY0NAotLS0gYS9zcmMvZ3JlcC5jCisrKyBiL3NyYy9ncmVwLmMKQEAgLTE2 NDYsNyArMTY0Niw3IEBAIGdyZXAgKGludCBmZCwgc3RydWN0IHN0YXQgY29uc3QgKnN0LCBi b29sICppbmVvZikKICBmaW5pc2hfZ3JlcDoKICAgZG9uZV9vbl9tYXRjaCA9IGRvbmVfb25f bWF0Y2hfMDsKICAgb3V0X3F1aWV0ID0gb3V0X3F1aWV0XzA7Ci0gIGlmIChiaW5hcnlfZmls ZXMgPT0gQklOQVJZX0JJTkFSWV9GSUxFUyAmJiAhIChvdXRfcXVpZXQgfCBzdXBwcmVzc19l cnJvcnMpCisgIGlmIChiaW5hcnlfZmlsZXMgPT0gQklOQVJZX0JJTkFSWV9GSUxFUyAmJiAh b3V0X3F1aWV0CiAgICAgICAmJiAoZW5jb2RpbmdfZXJyb3Jfb3V0cHV0CiAgICAgICAgICAg fHwgKDAgPD0gbmxpbmVzX2ZpcnN0X251bGwgJiYgbmxpbmVzX2ZpcnN0X251bGwgPCBubGlu ZXMpKSkKICAgICBlcnJvciAoMCwgMCwgXygiJXM6IGJpbmFyeSBmaWxlIG1hdGNoZXMiKSwg aW5wdXRfZmlsZW5hbWUgKCkpOwpkaWZmIC0tZ2l0IGEvdGVzdHMvYmluYXJ5LWZpbGUtbWF0 Y2hlcyBiL3Rlc3RzL2JpbmFyeS1maWxlLW1hdGNoZXMKaW5kZXggN2ZjNGExMS4uOGZlYTA3 MSAxMDA3NTUKLS0tIGEvdGVzdHMvYmluYXJ5LWZpbGUtbWF0Y2hlcworKysgYi90ZXN0cy9i aW5hcnktZmlsZS1tYXRjaGVzCkBAIC0xNCw4ICsxNCwxMCBAQCBmYWlsPTAKIGVjaG8gImdy ZXA6IChzdGFuZGFyZCBpbnB1dCk6IGJpbmFyeSBmaWxlIG1hdGNoZXMiID4gZXhwIFwKICAg fHwgZnJhbWV3b3JrX2ZhaWx1cmVfCiAKLXByaW50ZiAnYVwwJyB8IGdyZXAgYSA+IG91dCAy PiBlcnIgfHwgZmFpbD0xCi1jb21wYXJlIC9kZXYvbnVsbCBvdXQgfHwgZmFpbD0xCi1jb21w YXJlIGV4cCBlcnIgfHwgZmFpbD0xCitmb3Igb3B0aW9uIGluICcnIC1zOyBkbworICBwcmlu dGYgJ2FcMCcgfCBncmVwICRvcHRpb24gYSA+IG91dCAyPiBlcnIgfHwgZmFpbD0xCisgIGNv bXBhcmUgL2Rldi9udWxsIG91dCB8fCBmYWlsPTEKKyAgY29tcGFyZSBleHAgZXJyIHx8IGZh aWw9MQorZG9uZQogCiBFeGl0ICRmYWlsCi0tIAoyLjMyLjAKCg== --------------qE14K4VDscsvfe7BrPdpQtia-- ------------=_1637478002-27633-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 15 Nov 2021 06:07:36 +0000 Received: from localhost ([127.0.0.1]:52323 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmV9U-0001c2-5P for submit@debbugs.gnu.org; Mon, 15 Nov 2021 01:07:36 -0500 Received: from lists.gnu.org ([209.51.188.17]:39612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmV9S-0001bu-Ov for submit@debbugs.gnu.org; Mon, 15 Nov 2021 01:07:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmV9S-00088Y-Ja for bug-grep@gnu.org; Mon, 15 Nov 2021 01:07:34 -0500 Received: from [2607:f8b0:4864:20::102d] (port=41693 helo=mail-pj1-x102d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmV9P-0000lZ-SQ for bug-grep@gnu.org; Mon, 15 Nov 2021 01:07:34 -0500 Received: by mail-pj1-x102d.google.com with SMTP id gx15-20020a17090b124f00b001a695f3734aso13110897pjb.0 for ; Sun, 14 Nov 2021 22:07:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wqfPZ5mOoPTBmZxM4jCwGvp0g39iEgORAMGhawHlYPc=; b=WTTfR6KdwS1ZYh4DuLuiQ32KauDbHpWJyvKEaAlc9L+Djw3CQeUDtoRVCg1TudMoXm cP6glm29JOD2BVgAFEvyqJYPTAYrJi2K4Isx7E5cbr8z0QZP93vzy3s+Ic9O/oXEulRd fgoRDDmsZb9j5pFPcuIVjSUAijO2RGUCZgQxYea9rKpJHoCE11Z/vM9W19P2ZFVBGjDE G2nIUL29V8CxJdJNMCFj4MErS5l8L05K6yH14qi9Uopn+3fR1IJm5hJrzLP1oJnRg+WC BhFP1d1IPuGImFiD5VoeouUsvtWw1E6Ffn2VAWD4KkO8naTis3mAPlvYoz07vXs2tH6F QBHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=wqfPZ5mOoPTBmZxM4jCwGvp0g39iEgORAMGhawHlYPc=; b=YIVR/xj+9DPPjNMHH+H6moJyCgInUYl+LSCF72A2gVToCNsSr/xAS93JrTsYYcKQMz k9AE7uOWO9J8cSsrgKGrGl+GB6uVhyuW/Vswn7Irwt01EeS+ZydG6o4SyMpXafQOb5kx bWzbDYJilTZ6Cc5jyhx14oeuwmchMGtJC36L0NQH0XHVGSOeKokczwDRLg/yjBFkqAB2 MhKdNf+IC06kfZxfOPwDw0HoYccSUD+3kpI+G8PaAzEGm4qo5XAsGda+6PJDGdi86wOV jx7Vg2TxM+mRPgISrxYsvJDyMARKeAy3ETRecZHI5XDxCm0hJDxiZcM2DTZtwSvsztAI aW/g== X-Gm-Message-State: AOAM533ZJjE/PJu38Ys5VuHFEBoEheAVK8ZaZtO/Nr1jehrqfpVWE10B 7xGY0sT5KKaL/LQhMOyCCzDkCy4m8wk= X-Google-Smtp-Source: ABdhPJwm1Hcde95z4SDVjfp1d/2e74wqDrdwgbS08ptk7pxq7Wq1KssN78i2Ba2twLiLbB3nvvAxUw== X-Received: by 2002:a17:90b:1d81:: with SMTP id pf1mr24956043pjb.134.1636956449350; Sun, 14 Nov 2021 22:07:29 -0800 (PST) Received: from slk1.local.net (n110-23-108-30.sun3.vic.optusnet.com.au. [110.23.108.30]) by smtp.gmail.com with ESMTPSA id w5sm14525668pfu.219.2021.11.14.22.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Nov 2021 22:07:28 -0800 (PST) From: Duncan Roe To: bug-grep@gnu.org Subject: [PATCH] Reinstate Binary file matches to stdout Date: Mon, 15 Nov 2021 17:06:29 +1100 Message-Id: <20211115060629.19131-1-duncan_roe@optusnet.com.au> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=duncan.roe2@gmail.com; helo=mail-pj1-x102d.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit Cc: Duncan Roe X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) Revert commit 271793f0. * NEWS: Mention this. * doc/grep.texi: remove 1 line added in 271793f0. * src/grep.c (grep): Send traditional "Binary file FOO matches" to stdout again. * tests/surrogate-pair: test for traditional behaviour (test updated since 271793f0). * tests/null-byte: Reverted (non-conflicting changes since 271793f0). * tests/encoding-error, tests/invalid-multibyte-infloop: * tests/pcre-count, tests/symlink, tests/unibyte-binary: Reverted (unchanged since 271793f0). * tests/binary-file-matches: test for traditional behavior (new test). Signed-off-by: Duncan Roe --- NEWS | 6 ++++++ doc/grep.texi | 3 +-- src/grep.c | 8 ++++++-- tests/binary-file-matches | 6 +++--- tests/encoding-error | 5 +++-- tests/invalid-multibyte-infloop | 4 +++- tests/null-byte | 2 +- tests/pcre-count | 5 +++-- tests/surrogate-pair | 12 ++++++++---- tests/symlink | 6 +++++- tests/unibyte-binary | 2 +- 11 files changed, 40 insertions(+), 19 deletions(-) diff --git a/NEWS b/NEWS index 2f63071..0173187 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,12 @@ GNU grep NEWS -*- outline -*- ** Changes in behavior + The message that a binary file matches is again sent to standard output + with the wording as it was before release 3.5. The -I option is available + to suppress this message if so desired. The behavior in grep 3.5 + through 3.7 prevented a user seeing binary matches when using + grep -s to suppress error messages. + The -P option is now based on PCRE2 instead of the older PCRE, thanks to code contributed by Carlo Arenas. diff --git a/doc/grep.texi b/doc/grep.texi index c3c4bbf..2482fa0 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -1819,8 +1819,7 @@ to output lines even from files that appear to be binary, use the @option{-a} or @samp{--binary-files=text} option. To eliminate the ``Binary file matches'' messages, use the @option{-I} or -@samp{--binary-files=without-match} option, -or the @option{-s} or @option{--no-messages} option. +@samp{--binary-files=without-match} option. @item Why doesn't @samp{grep -lv} print non-matching file names? diff --git a/src/grep.c b/src/grep.c index a55194c..0e60023 100644 --- a/src/grep.c +++ b/src/grep.c @@ -1646,10 +1646,14 @@ 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 ()); + { + printf_errno (_("Binary file %s matches\n"), input_filename ()); + if (line_buffered) + fflush_errno (); + } return nlines; } diff --git a/tests/binary-file-matches b/tests/binary-file-matches index 7fc4a11..dc4c3e7 100755 --- a/tests/binary-file-matches +++ b/tests/binary-file-matches @@ -11,11 +11,11 @@ fail=0 -echo "grep: (standard input): binary file matches" > exp \ +echo "Binary file (standard input) 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 +compare /dev/null err || fail=1 +compare exp out || fail=1 Exit $fail diff --git a/tests/encoding-error b/tests/encoding-error index 2ec71c9..9fb496c 100755 --- a/tests/encoding-error +++ b/tests/encoding-error @@ -25,7 +25,8 @@ grep '^A' in >out || fail=1 compare a out || fail=1 grep '^P' in >out || fail=1 -compare /dev/null out || fail=1 +printf 'Binary file in matches\n' >exp || framework_failure_ +compare exp out || fail=1 grep -I '^P' in >out 2>err || fail=1 compare /dev/null out || fail=1 @@ -38,7 +39,7 @@ returns_ 1 grep '^X' in >out || fail=1 compare /dev/null out || fail=1 grep . in >out || fail=1 -cat a j >exp || framework_failure_ +(cat a j && printf 'Binary file in matches\n') >exp || framework_failure_ compare exp out || fail=1 grep -I . in >out 2>err || fail=1 diff --git a/tests/invalid-multibyte-infloop b/tests/invalid-multibyte-infloop index b4ad14b..5b3bdfc 100755 --- a/tests/invalid-multibyte-infloop +++ b/tests/invalid-multibyte-infloop @@ -24,10 +24,12 @@ else test $status -eq 2 fi || fail=1 +echo 'Binary file input matches' >binary-file-matches + LC_ALL=en_US.UTF-8 timeout 10 grep -F $(encode A) input > out status=$? if test $status -eq 0; then - compare /dev/null out + compare binary-file-matches out elif test $status -eq 1; then compare_dev_null_ /dev/null out else diff --git a/tests/null-byte b/tests/null-byte index d86c249..9354aaf 100755 --- a/tests/null-byte +++ b/tests/null-byte @@ -56,7 +56,7 @@ echo xxx >exp || framework_failure_ grep xxx in >out || fail=1 compare exp out || fail=1 -printf 'xxx\n' > exp || framework_failure_ +printf '%s\n' xxx 'Binary file in matches' > exp || framework_failure_ grep -E 'xxx|z' in >out || fail=1 compare exp out || fail=1 diff --git a/tests/pcre-count b/tests/pcre-count index 9eda54b..656780e 100755 --- a/tests/pcre-count +++ b/tests/pcre-count @@ -17,9 +17,10 @@ printf 'a\n%032768d\nb\0\n%032768d\na\n' 0 0 > in || framework_failure_ # grep will discover that the input is a binary file sooner if the # page size is larger, so allow for either possible output. -printf 'a\n' >exp1a || framework_failure_ +printf 'a\nBinary file in matches\n' >exp1a || framework_failure_ +printf 'Binary file in matches\n' >exp1b || framework_failure_ LC_ALL=C grep -P 'a' in >out || fail=1 -compare exp1a out || compare /dev/null out || fail=1 +compare exp1a out || compare exp1b out || fail=1 printf '2\n' >exp2 || framework_failure_ LC_ALL=C grep -Pc 'a' in >out || fail=1 diff --git a/tests/surrogate-pair b/tests/surrogate-pair index a91fa36..7f8373a 100755 --- a/tests/surrogate-pair +++ b/tests/surrogate-pair @@ -26,6 +26,10 @@ fail=0 s_pair=$(printf '\360\220\220\205') printf '%s\n' "$s_pair" > in || framework_failure_ +# On platforms where wchar_t is only 16 bits, wchar_t cannot represent +# the character encoded in 'in', so accept that behavior too. +printf 'Binary file in matches\n' > out16 || framework_failure_ + LC_ALL=en_US.UTF-8 export LC_ALL @@ -41,12 +45,12 @@ grep . in > out 2> err || fail=1 # On platforms where wchar_t is only 16 bits, wchar_t cannot represent # the character encoded in 'in'. -# On such old systems the above prints nothing on stdout and a diagnostic -# on stderr. In that case, return early; otherwise, the following tests +# On such old systems the above prints diagnostic on stdout. +# In that case, return early; otherwise, the following tests # would all fail. io_pair=$(cat out):$(cat err) case $io_pair in - :'grep: in: binary file matches') Exit $fail;; + 'Binary file in matches:') Exit $fail;; $s_pair:) ;; *) fail_ "unexpected output: $io_pair"; fail=1;; esac @@ -54,7 +58,7 @@ esac # Also test whether a surrogate-pair in the search string works. for opt in '' -i -E -F -iE -iF; do grep --file=in $opt in > out 2>&1 || fail=1 - compare out in || fail=1 + compare out in || compare out out16 || fail=1 done Exit $fail diff --git a/tests/symlink b/tests/symlink index b580ce7..427dfed 100755 --- a/tests/symlink +++ b/tests/symlink @@ -58,7 +58,11 @@ do printf "$exp" >exp || framework_failure_ - LC_ALL=C sort grepout >out || fail=1 + LC_ALL=C sort grepout >out-t || fail=1 + + # Ignore "Binary file d matches" on systems for which + # reading from a directory actually succeeds. + grep -v Binary out-t > out; case $? in 0|1) ;; *) fail=1;; esac compare exp out || fail=1 done diff --git a/tests/unibyte-binary b/tests/unibyte-binary index f76276f..7e8f2aa 100755 --- a/tests/unibyte-binary +++ b/tests/unibyte-binary @@ -22,7 +22,7 @@ require_unibyte_locale fail=0 printf 'a\n\200\nb\n' >in || framework_failure_ -printf 'a\n' >exp || framework_failure_ +printf 'a\nBinary file in matches\n' >exp || framework_failure_ grep . in >out || fail=1 # In some unibyte locales, \200 is an encoding error; -- 2.33.1 ------------=_1637478002-27633-1-- From unknown Sat Aug 16 22:46:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#51860: [PATCH] Reinstate Binary file matches to stdout Resent-From: Duncan Roe Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Tue, 23 Nov 2021 00:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51860 X-GNU-PR-Package: grep X-GNU-PR-Keywords: patch To: Paul Eggert Cc: 51860-done@debbugs.gnu.org Received: via spool by 51860-done@debbugs.gnu.org id=D51860.163762786531841 (code D ref 51860); Tue, 23 Nov 2021 00:38:01 +0000 Received: (at 51860-done) by debbugs.gnu.org; 23 Nov 2021 00:37:45 +0000 Received: from localhost ([127.0.0.1]:49429 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mpJoe-0008HV-Qx for submit@debbugs.gnu.org; Mon, 22 Nov 2021 19:37:45 -0500 Received: from mail-pl1-f169.google.com ([209.85.214.169]:35822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mpJoc-0008HH-7i for 51860-done@debbugs.gnu.org; Mon, 22 Nov 2021 19:37:43 -0500 Received: by mail-pl1-f169.google.com with SMTP id b13so15589238plg.2 for <51860-done@debbugs.gnu.org>; Mon, 22 Nov 2021 16:37:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wlXVeMUSlIYjWS5pSLVqxi9i35iF+uDq4zakFL4WODY=; b=lk0JCIJHoNup4S+P2G5BAI5+YmbNj6IjEjz0UhZRNXTRIV5+T/io9EnDyRxiGgMTTx +zH1GhxmkHARv5r8Gao1XFBDece/7VY198KgWYHu5sNL6OzDwoYfxmr9WUmagzssEiIe BVAsEW7qkPCaWc3h1Wz+7Qn+bE/dV+GGnsJVOMDdciApRD5UeS7jrgD50AGuZ6LDjMxB FnnjBiNZK+d+veyPVtx5OhisgArCgyZd38CtI/x8/bDNtoXZgea5ZjrXZIcgGkBHYj1x N2G94wmoQ0tMddNxQCeXDOzayySE/tpDTmiuXXPyLAOClfqIE68dQWzTzP8hMQzBKYkK cWVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=wlXVeMUSlIYjWS5pSLVqxi9i35iF+uDq4zakFL4WODY=; b=oFn2BsgWg0fI+NpvMEAghIMk1gAM38KHDH1opHwGjdJpTqSTDdGga2eHRW4dns/5pv 3ImyyB+WdT2AfUorASQbp0EvLCDP1Qsj/DpLidXBOKbcOyPWR97Xr6etpHP2SJ70cZKQ l71GpT5LrrxDPI+jUR3wyxRvOBRsbk/pWohCcFxxZYgE20Yn3ScCGVvQsosVDbRO5vpy RxtLOO+i7XcOV4kJ2cBagcl694KfISBYBd+KgA8NUs4AjrtXKOblFUp7ZHQ5EdjBM+/t w/BEyuVrRSGiIP3QbK6c9mL8y7OIMTaRV8sC0hF7kjz5PEB3M6i35xUuoy0OU8uSRfcx i0mQ== X-Gm-Message-State: AOAM5331LPxqAdYQH7Ifac+hqVgAGuhXHI//2FNReKapqILYTD1VF1h/ 6qriD0NwPtblhYXW/hdeV3g= X-Google-Smtp-Source: ABdhPJw0BYNrACYJ+cTpF8JVJIUuHHXgZCTep9iWowEz/emiGw4ZAwbXVFLTTXRStgbWF9WCo+snbw== X-Received: by 2002:a17:902:e804:b0:142:1c0b:c2a6 with SMTP id u4-20020a170902e80400b001421c0bc2a6mr1196245plg.23.1637627856441; Mon, 22 Nov 2021 16:37:36 -0800 (PST) Received: from slk1.local.net (n110-23-108-30.sun3.vic.optusnet.com.au. [110.23.108.30]) by smtp.gmail.com with ESMTPSA id g14sm7036432pgo.88.2021.11.22.16.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Nov 2021 16:37:35 -0800 (PST) From: Duncan Roe X-Google-Original-From: Duncan Roe Date: Tue, 23 Nov 2021 11:37:31 +1100 Message-ID: References: <20211115060629.19131-1-duncan_roe@optusnet.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) On Sat, Nov 20, 2021 at 10:59:43PM -0800, Paul Eggert wrote: > On 11/20/21 17:38, Duncan Roe wrote: > > > I'd further suggest biaary matches output to stderr by the new option be not > > affected by the setting of `-s`, only by `-I`. This reinstates orthogonality of > > -s and -I which 271793f0 broke. > > Hmm, you have a point that -s is documented to "Suppress error messages > about nonexistent or unreadable files" and it's plausible to say that the > "binary file matches" diagnostic, although it is about a binary file that > 'grep' has some trouble reading, is not about a file that is "unreadable". > So, let's fix the code to match that part of the spec again. Second patch > attached and installed. > Excellent. But I think you still need the patch below. Cheers ... Duncan. ======================= diff --git a/doc/grep.texi b/doc/grep.texi index c3c4bbf..2482fa0 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -1819,8 +1819,7 @@ to output lines even from files that appear to be binary, use the @option{-a} or @samp{--binary-files=text} option. To eliminate the ``Binary file matches'' messages, use the @option{-I} or -@samp{--binary-files=without-match} option, -or the @option{-s} or @option{--no-messages} option. +@samp{--binary-files=without-match} option. @item Why doesn't @samp{grep -lv} print non-matching file names? From unknown Sat Aug 16 22:46:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#51860: [PATCH] Reinstate Binary file matches to stdout Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Tue, 23 Nov 2021 02:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51860 X-GNU-PR-Package: grep X-GNU-PR-Keywords: patch To: Duncan Roe Cc: 51860-done@debbugs.gnu.org Received: via spool by 51860-done@debbugs.gnu.org id=D51860.16376338049126 (code D ref 51860); Tue, 23 Nov 2021 02:17:01 +0000 Received: (at 51860-done) by debbugs.gnu.org; 23 Nov 2021 02:16:44 +0000 Received: from localhost ([127.0.0.1]:49498 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mpLMR-0002N7-RY for submit@debbugs.gnu.org; Mon, 22 Nov 2021 21:16:44 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33376) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mpLMQ-0002Mu-6i for 51860-done@debbugs.gnu.org; Mon, 22 Nov 2021 21:16:42 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E96F9160051; Mon, 22 Nov 2021 18:16:36 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id mDZp0ELvD-GK; Mon, 22 Nov 2021 18:16:36 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 54E4E160108; Mon, 22 Nov 2021 18:16:36 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Zrt4v-FNoAMe; Mon, 22 Nov 2021 18:16:36 -0800 (PST) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 2D8E01600BC; Mon, 22 Nov 2021 18:16:36 -0800 (PST) Message-ID: <3f6bc615-2878-5c7d-1f6d-56ad45a0d69d@cs.ucla.edu> Date: Mon, 22 Nov 2021 18:16:35 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Content-Language: en-US References: <20211115060629.19131-1-duncan_roe@optusnet.com.au> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.4 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) On 11/22/21 16:37, Duncan Roe wrote: > I think you still need the patch below. Thanks for reporting that; I installed the patch.