bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#47649: grep bug report - improper handling of file symlinks with -r


From: Chris Drake
Subject: bug#47649: grep bug report - improper handling of file symlinks with -r option
Date: Sat, 7 Aug 2021 21:43:08 +1000

Hi Jim,

Looks like the -r and -R got mixed up?

What is now the "-R" behaves the same way as the original "-r", and now the
new "-r" behaves differently.

For backwards-compatibility, the original behaviour should have been
preserved, and the new feature assigned to a new switch ?

On Sat, Aug 7, 2021 at 3:10 PM Jim Meyering <jim@meyering.net> wrote:

> tags 47649 notabug
> close 47649
> done
>
> On Wed, Apr 7, 2021 at 7:21 PM Chris Drake <cryptophoto@gmail.com> wrote:
> > *This is the original working grep behaviour - it found text inside files
> > that were symlinks:-*
> > (Note the output: "*./folder/testfile1:this is my test file*")
> >
> > [root@ir2 ~]# grep --version
> > grep (GNU grep) 2.5.1
> >
> > Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions. There is NO
> > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.
> >
> > [root@ir2 ~]# mkdir bugdemo
> > [root@ir2 ~]# cd bugdemo
> > [root@ir2 bugdemo]# echo "this is my test file" > testfile1
> > [root@ir2 bugdemo]# echo "this is my test file" > testfile2
> > [root@ir2 bugdemo]# mkdir folder
> > [root@ir2 bugdemo]# cd folder
> > [root@ir2 folder]# echo "this is my test file" > testfile3
> > [root@ir2 folder]# ln -s ../testfile1
> > [root@ir2 folder]# cd ..
> > [root@ir2 bugdemo]# unalias grep
> > [root@ir2 bugdemo]# grep -r test .
> > ./testfile2:this is my test file
> > ./folder/testfile1:this is my test file
> > ./folder/testfile3:this is my test file
> > ./testfile1:this is my test file
> > [root@ir2 bugdemo]#
> ...
> > It looks like processing exists to not recursively follow symlinks, and
> > someone has messed with that which has caused files to no longer be
> > searched by mistake.
>
> Thanks for the report, but that is the documented behavior of -r.
> You appear to prefer -R:
>
> ‘-r’
> ‘--recursive’
>      For each directory operand, read and process all files in that
>      directory, recursively.  Follow symbolic links on the command line,
>      but skip symlinks that are encountered recursively.  Note that if
>      no file operand is given, grep searches the working directory.
>      This is the same as the ‘--directories=recurse’ option.
>
> ‘-R’
> ‘--dereference-recursive’
>      For each directory operand, read and process all files in that
>      directory, recursively, following all symbolic links.
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]