With is rather like if ... else .... so maybe:

When FILE is '-', read standard input.  If no FILE is given, with -r, 
recursively search the working directory instead, else read standard input.  
With fewer than two FILEs, assume -h.  Exit status is 0 if any line is 
selected, 1 otherwise; if any error occurs and -q is not given, the exit status 
is 2.


 

    On Thursday, January 16, 2025 at 12:03:41 AM EST, Jim Meyering 
<j...@meyering.net> wrote:   

 On Wed, Jan 15, 2025 at 8:16 PM sur-behoffski
<sur-behoff...@grouse.com.au> wrote:
> On 2025-01-16 08:05, Paul Eggert wrote:
> > On 2025-01-15 02:51, Anton Samokat wrote:
> >> Please, make it more simple and straightforward, remove possible ambiguity
> >
> > Unfortunately these are competing goals.
> >
> > Perhaps this would be better:
> >
> > If no FILE is given read standard input, but if -r is given recursively
> > search the working directory instead.
> > [...]
>
> Interesting.  How about:
>
>    If no FILE is given, grep's behaviour depends on the -r (recursive)
>    option, which is disabled (non-recursive) by default:
>
>        - If non-recursive, then read standard input; otherwise
>        - If recursive, examine all files in the working directory,
>          including recursively descending into subdirectories.
>
> No idea if this is good, bad, or indifferent... others can decide.

Thanks for the suggestions. I went with Paul's (keeping it concise is
important), so --help now prints this:

When FILE is '-', read standard input.  If no FILE is given, read standard
input, but with -r, recursively search the working directory instead.  With
fewer than two FILEs, assume -h.  Exit status is 0 if any line is selected,
1 otherwise; if any error occurs and -q is not given, the exit status is 2.

Here's the commit:
https://git.savannah.gnu.org/cgit/grep.git/commit/?id=v3.11-56-gfc6aba9

Marking this as done.



  

Reply via email to