Subject: grep: option to filter non-printable characters from contents

From: "Santiago R.R." <[email-masked]>
Date: Thu, 31 Aug 2017 17:38:19 +0200

Dear grep upstream authors,

I'd like to forward this bug reported to debian
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498336

On Tue, 9 Sep 2008 11:07:33 +0200 Vincent Lefevre <[email-masked]> wrote:
…
> 
> grep should have an option to filter non-printable characters from
> the contents (file contents, but also filenames -- see bug #42630)
> *before coloring*. The values could be "never", "always" and "auto",
> like with --color.
> 
> Such an option would be useful because:
> 
> 1. The option --binary-files is a heuristic only; the user may want
>    to have more information on binary files anyway.
> 
> 2. It is not even possible to write a wrapper script when coloring is
>    used, because after coloring, it is not possible (or at least very
>    difficult) to do the difference between escape sequences from grep
>    and those from the original contents.
> 
> Such non-printable characters could be either replaced by some
> locale-specific replacement character or transcoded.
> 
> I wonder whether filtering should be the default when the output
> is connected to a terminal (and when POSIXLY_CORRECT is not set).
> It would not be worse than the default --binary-files=binary.
…

This option could be also useful to filter undesirable behaviors, such
as ringing the bell terminal (from stdin in this case):

    printf '\a'x | grep x

What's your position on this?

Thanks,

  -- Santiago

PS. As Vincent Lefevre says, this bug relates to filtering non-printable
characters from filenames:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=42630