> The input files shall be text files.
"Text file" is defined in https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1... :
> A file that contains characters organized into zero or more lines. The lines do not contain NUL characters and none can exceed {LINE_MAX} bytes in length, including the <newline> character.
Interesting, especially the part about the LINE_MAX. Even though it kinda makes sense, I would never have thought that having a very long line makes a file a non-text file when all characters are 'normal' characters.
And I also think that this would not be a discussion if it was just about NUL. There is something else that grep does not like (escape characters? Invalid utf8? Wrong codepage? I don't know), but this makes the binary detection annoying.
$ printf 'a\222b' | LC_ALL=en_US.UTF-8 grep a
Binary file (standard input) matches
This is POSIX-compliant, because "character" is defined as:> A sequence of one or more bytes representing a single graphic symbol or control code.
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1...
At a glance, I couldn't find a reference on the grep page:
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/g...