On April 30, 2015 2:02:23 PM GMT+02:00, "Todd C. Miller" <todd.mil...@courtesan.com> wrote: >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.
I think the warning is wrong. -R is only said to affect directories passed as arguments, right? I'm inclined to say this is excessive hand holding. /Alexander > > - 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)