On Mon, Dec 02, 2019 at 08:31:02AM +0000, Miod Vallat wrote:
> grep(1), when invoked with the -R option but no path, displays a
> "recursive search of stdin" warning and acts as if -R had not been
> specified.
>
> GNU grep, in that case, will perform a recursive search in the current
> directory, i.e. uses an implicit "." path if none is given.
>
> This is IMO a much better behaviour. What about the following diff?
>
> Index: grep.c
> ===================================================================
> RCS file: /OpenBSD/src/usr.bin/grep/grep.c,v
> retrieving revision 1.62
> diff -u -p -r1.62 grep.c
> --- grep.c 7 Oct 2019 20:04:00 -0000 1.62
> +++ grep.c 2 Dec 2019 08:27:09 -0000
> @@ -473,8 +473,12 @@ main(int argc, char *argv[])
> ++argv;
> }
>
> - if (Rflag && argc == 0)
> - warnx("warning: recursive search of stdin");
> + if (Rflag && argc == 0) {
> + /* default to . if no path given */
> + static char *dot_argv[] = { ".", NULL };
> + argv = dot_argv;
> + argc = 1;
> + }
> if (Eflag)
> cflags |= REG_EXTENDED;
> if (Fflag)
>
>
I concur, I like it better as well.
-R isn't in POSIX anyway, so we don't have to worry about standard.