On Thu, 30 Apr 2015 05:58:57 -0600, "Todd C. Miller" wrote: > GNU grep warns in this case before reading from stdin which seems reasonable. > % grep -R foo > grep: warning: recursive search of stdin > ... > > I'd rather add a warning than change the behavior.
Trivial diff to add the warning. - todd Index: usr.bin/grep/grep.c =================================================================== RCS file: /cvs/src/usr.bin/grep/grep.c,v retrieving revision 1.50 diff -u -p -u -r1.50 grep.c --- usr.bin/grep/grep.c 16 Mar 2015 13:27:59 -0000 1.50 +++ usr.bin/grep/grep.c 30 Apr 2015 12:01:32 -0000 @@ -444,6 +444,8 @@ main(int argc, char *argv[]) ++argv; } + if (Rflag && argc == 0) + warnx("warning: recursive search of stdin"); if (Eflag) cflags |= REG_EXTENDED; if (Fflag)