El 03/12/14 a las 07:32, Jim Meyering escribió: > On Wed, Dec 3, 2014 at 7:05 AM, <santi...@debian.org> wrote: > > I'm forwarding a bug report filed in debian. Is this the expected > > behavior? > > > > /tmp/greptest % dpkg -l | grep -r grep > > wtf:hello grep > > /tmp/greptest % dpkg -l | grep grep > > ii grep 2.21-1 > > amd64 GNU grep, egrep and fgrep > > > > grep -r takes the current dir as input instead of stdin. > > Hi Santiago, > > That is the expected/documented behavior. > It was changed upstream 2.5 years ago (as seen in the NEWS file): > > * Noteworthy changes in release 2.11 (2012-03-02) [stable] > > ** Bug fixes > ... > ** New features > > If no file operand is given, and a command-line -r or equivalent > option is given, grep now searches the working directory. Formerly > grep ignored the -r and searched standard input nonrecursively. > An -r found in GREP_OPTIONS does not have this new effect. > -------------------- > > Note that GREP_OPTIONS has recently been deprecated, > so this functionality will disappear.
Jim, thanks for clarifying this. Please, find attached a simple patch to document this in the man page and info doc. Regards, Santiago
diff --git a/doc/grep.in.1 b/doc/grep.in.1 index b6362ee..e8334cb 100644 --- a/doc/grep.in.1 +++ b/doc/grep.in.1 @@ -470,6 +470,7 @@ following symbolic links only if they are on the command line. This is equivalent to the .B "\-d recurse" option. +Note that if no file operand is given, grep searches the working directory. .TP .BR \-R ", " \-\^\-dereference\-recursive Read all files under each directory, recursively. diff --git a/doc/grep.texi b/doc/grep.texi index da9a1be..b495cf7 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -699,6 +699,7 @@ read and process all files in that directory, recursively. Follow symbolic links on the command line, but skip symlinks that are encountered recursively. This is the same as the @samp{--directories=recurse} option. +Note that if no file operand is given, grep searches the working directory. @item -R @itemx --dereference-recursive