Should both -r and file names raise an error?
$ grep -r xxx yyy zzzgrep: yyy: No such file or directorygrep: zzz: No such
file or directory$
On Thursday, January 16, 2025 at 11:53:29 PM EST, [email protected]
<[email protected]> wrote:
sur-behoffski wrote:
>> Blending in documentation about -h immediately made me curious.
Speaking off the cuff, without benefit of looking at the code or sufficient
experimenting with the behavior, I would expect that:
By default, if more than one file argument is named on the command line or is
potentially implied by the "-r" recursive option, grep prefixes each line of
output with the file name in which it was found, whereas if only one file is
explicitly named, or only the standard input is being searched, then grep
suppresses the prefixing of file names on output. The "-h" and "-H" options
override these defaults, to either never ("-h") or always ("-H") prefix each
line of output with the file name in which it was found. If "-H" is specified
and grep is searching its standard input, that input file name prefix is the
string "(standard input)".
Clearly my previous paragraph fails the "keep word count parsimonious" mandate
for man pages. Perhaps the two man page paragraphs, one for "-h" and the next
one for "-H", could be combined into a single paragraph, derived from some
parsimonious variant of my above paragraph, explaining both the "-h" and "-H"
options.
--
Paul Jackson
[email protected]