On Mon, Dec 02 2019, Marc Espie <[email protected]> wrote: > 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.
Same here, even if muscle memory helps this is just a better default IMO. I have had a similar diff for some time but didn't push for it because nitpicking: GNU grep doesn't prepend "./" to file names in this case. I have a diff to do this but let's keep the nitpicking for later. I'd like us to go with Miod's diff. Any objection? oks? ok jca@ if Marc or someone else wants to commit it. -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
