From unknown Fri Jun 20 20:09:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47649: grep bug report - improper handling of file symlinks with -r option Resent-From: Chris Drake Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Thu, 08 Apr 2021 02:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47649 X-GNU-PR-Package: grep X-GNU-PR-Keywords: To: 47649@debbugs.gnu.org X-Debbugs-Original-To: bug-grep@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.161784782819386 (code B ref -1); Thu, 08 Apr 2021 02:11:01 +0000 Received: (at submit) by debbugs.gnu.org; 8 Apr 2021 02:10:28 +0000 Received: from localhost ([127.0.0.1]:45618 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lUK7n-00052c-UF for submit@debbugs.gnu.org; Wed, 07 Apr 2021 22:10:28 -0400 Received: from lists.gnu.org ([209.51.188.17]:41556) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lUHtA-0001WP-TQ for submit@debbugs.gnu.org; Wed, 07 Apr 2021 19:47:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUHtA-0000IK-Ki for bug-grep@gnu.org; Wed, 07 Apr 2021 19:47:12 -0400 Received: from mail-ua1-x92a.google.com ([2607:f8b0:4864:20::92a]:46781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUHt8-0004Y7-IW for bug-grep@gnu.org; Wed, 07 Apr 2021 19:47:12 -0400 Received: by mail-ua1-x92a.google.com with SMTP id v23so121290uaq.13 for ; Wed, 07 Apr 2021 16:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=VHlnJi6+4OY0s4ZFaVrXbSpZ52MdTithJ6yMFo95CAo=; b=ZvTN6+5Rs3P1lvFgFablPlsmF481+qfNJCd7ZlDrO+215S3LPKuG4I9AQ5GYKKB/Xd uqpBg4dDhHJWeCVSGwPakwxCGB917PE4paTPp4NPsysRj45wC3c0eiN4a6tjmLKqZUCI 2rKCkmv9122P9RblCKzDRav3dqXd9IxK7Al4vmAtCz8duJRi5OHpCLjvI1mJc8pe5FZW F65LZ7+FSsOdeIBaL6UbbxGiQMJi7X4NPIe/BvISx+NFOIxPhwkf9u7ku+cMPxm+PfYS 5880T6HAi4bfkQ7qW99SVaTOmCKCrb8r+ZtM8zkL5Hqu8QMhn7Ck58OE9GUsS6E7TPbz Kw/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=VHlnJi6+4OY0s4ZFaVrXbSpZ52MdTithJ6yMFo95CAo=; b=U9xO8StJxqBdfoX9tpHLPuxtYQH13hwdsdgZrRrggMf06AsrvLF8W3hUKXwahyIy+M SKJ5dpE4+z/u+kxj2FiXs7irSfQy8Ae7eBdwmOW2YMRJA7OLwHmmLlL9znXRVkpx3eiw 5qDu1mMZfMLxor4N1LKabvYCVnGxW7xHvnkb8cPcyf+Ly+TYTxVmqqro9K2trl8MZ42h Nesyb5Neuu41QyqdMunhRvXX+jBzFAAAaW6bC1ZQCHqOXBUSvlm98OzQWsAtXNmYy796 m1o1mug20cDUvPzAulBaSOOC4tvZKAXZ1WWfhQmPgDrFNVk2PShhfbVeLhDDyALSAmH8 kmtQ== X-Gm-Message-State: AOAM531ieqr2lhRJ5FBYTuoU84oMgUo6+wxghi3ux2kI+GKHpVUcLV8J xVNjoBR+22/fsOxudAH0/D4ufdkP7hf52fLl8MQAX2ejdqM= X-Google-Smtp-Source: ABdhPJz+UtDyNRTqhjdvBzCXAlEQvMTcqWtOgLcxQtGpFUY+um6t9Mm2CW1Bs18HvjL0+f8bn1bJAlPJQ45kF3fVPvo= X-Received: by 2002:a9f:36a3:: with SMTP id p32mr4026960uap.22.1617839228733; Wed, 07 Apr 2021 16:47:08 -0700 (PDT) MIME-Version: 1.0 From: Chris Drake Date: Thu, 8 Apr 2021 09:46:57 +1000 Message-ID: Content-Type: multipart/alternative; boundary="000000000000884c3f05bf6a8c8b" Received-SPF: pass client-ip=2607:f8b0:4864:20::92a; envelope-from=cryptophoto@gmail.com; helo=mail-ua1-x92a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Mailman-Approved-At: Wed, 07 Apr 2021 22:10:26 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --000000000000884c3f05bf6a8c8b Content-Type: text/plain; charset="UTF-8" *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]# *This is the now-broken current non-working grep behaviour - it fails to find text inside files that were symlinks:-* (Note the *missing* output: "*./folder/testfile1:this is my test file*") [root@ir3 ~]# grep --version grep (GNU grep) 3.1 Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Mike Haertel and others, see < http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>. [root@ir3 ~]# mkdir bugdemo [root@ir3 ~]# cd bugdemo [root@ir3 bugdemo]# echo "this is my test file" > testfile1 [root@ir3 bugdemo]# echo "this is my test file" > testfile2 [root@ir3 bugdemo]# mkdir folder [root@ir3 bugdemo]# cd folder [root@ir3 folder]# echo "this is my test file" > testfile3 [root@ir3 folder]# ln -s ../testfile1 [root@ir3 folder]# cd .. [root@ir3 bugdemo]# unalias grep [root@ir3 bugdemo]# grep -r test . ./testfile1:this is my test file ./testfile2:this is my test file ./folder/testfile3:this is my test file [root@ir3 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. --000000000000884c3f05bf6a8c8b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This is the original working grep behaviour - it f= ound 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

Cop= yright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This i= s free software; see the source for copying conditions. There is NO
warr= anty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
=
[root@ir2 ~]# mkdir bugdemo
[root@ir2 ~]# cd bugdemo
[root@ir2 bu= gdemo]# echo "this is my test file" > testfile1
[root@ir2 b= ugdemo]# 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]# un= alias 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 bugde= mo]#=C2=A0


This is the = now-broken current non-working grep behaviour - it fails to find text insid= e files that were symlinks:-
(Note the missing output:= "./folder/testfile1:this is my test file")

[root@ir3 ~]# grep --version
grep (GNU grep)= 3.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+= : GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you = are free to change and redistribute it.
There is NO WARRANTY, to the ext= ent permitted by law.

Written by Mike Haertel and others, see <http://git.sv.gn= u.org/cgit/grep.git/tree/AUTHORS>.
[root@ir3 ~]# mkdir bugdemo[root@ir3 ~]# cd bugdemo
[root@ir3 bugdemo]# echo "this is my test= file" > testfile1
[root@ir3 bugdemo]# echo "this is my tes= t file" > testfile2
[root@ir3 bugdemo]# mkdir folder
[root@ir= 3 bugdemo]# cd folder
[root@ir3 folder]# echo "this is my test file= " > testfile3
[root@ir3 folder]# ln -s ../testfile1
[root@ir3= folder]# cd ..
[root@ir3 bugdemo]# unalias grep
[root@ir3 bugdemo]# = grep -r test .
./testfile1:this is my test file
./testfile2:this is m= y test file
./folder/testfile3:this is my test file
[root@= ir3 bugdemo]#=C2=A0


It looks li= ke processing exists to not recursively follow symlinks, and someone has me= ssed with that which has caused files to no longer be searched by mistake.<= /div>
--000000000000884c3f05bf6a8c8b-- From unknown Fri Jun 20 20:09:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47649: grep bug report - improper handling of file symlinks with -r option Resent-From: Jim Meyering Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Sat, 07 Aug 2021 05:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47649 X-GNU-PR-Package: grep X-GNU-PR-Keywords: To: Chris Drake Cc: 47649@debbugs.gnu.org Received: via spool by 47649-submit@debbugs.gnu.org id=B47649.162831304517195 (code B ref 47649); Sat, 07 Aug 2021 05:11:01 +0000 Received: (at 47649) by debbugs.gnu.org; 7 Aug 2021 05:10:45 +0000 Received: from localhost ([127.0.0.1]:51767 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCEbd-0004TH-3k for submit@debbugs.gnu.org; Sat, 07 Aug 2021 01:10:45 -0400 Received: from mail-wr1-f50.google.com ([209.85.221.50]:35624) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCEbY-0004T1-75 for 47649@debbugs.gnu.org; Sat, 07 Aug 2021 01:10:43 -0400 Received: by mail-wr1-f50.google.com with SMTP id n12so3640831wrr.2 for <47649@debbugs.gnu.org>; Fri, 06 Aug 2021 22:10:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Et/ktTd4GQWgaC6eHmgKn97k8PeLo8dngTMMV58Hj4c=; b=VVJHHoI9moOyl9HA3Bt35cRdiZpTxMFHIanAmY1zl5ylp/0AHnZeE9LDhpywqvji3V jVmHQIx4qy+scvVyK16XAo4shh8ZAYgJHIL/iPq56NRsaLTbC6sYgPZ2C3oxe9goI40a iXwFLj/aa/MxXM3KMWXJrCQws3oBRjz3AGuyo35XlhFY0ep44jaoBmFJzXArNyyizRkK ZOEzTLxUX+zTQE1QTEDOnxY8UF9NqKJYHY3io0HBsWiikL/Z91brUXxr6hgbVRDsCJO/ H6JMTAXYSf3F4iig+tepUyRso6qh/b2Njr+cv78EGQ7RRRxEWDDbCxJfMxF4Sw/jx78D oMIg== X-Gm-Message-State: AOAM531cqW38idwDSiX+oph/gNcj7QJcdHE63uNGiNTGn+qfdwMFdbT5 NBm3V5WNQJ5ey6Fecr5zTvXfqqPAHGLHuT5VOSE= X-Google-Smtp-Source: ABdhPJwlgddOowjQy7LaJKI+gRR6gtMsE3CiXK540ALWCfMGLGwStwqUHdjS0xPiiTGe3HaY/9XqSy4lcZUQKJdoQpQ= X-Received: by 2002:a5d:658a:: with SMTP id q10mr14218556wru.343.1628313034566; Fri, 06 Aug 2021 22:10:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jim Meyering Date: Fri, 6 Aug 2021 22:10:22 -0700 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) tags 47649 notabug close 47649 done On Wed, Apr 7, 2021 at 7:21 PM Chris Drake 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 PURPOS= E. > > [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: =E2=80=98-r=E2=80=99 =E2=80=98--recursive=E2=80=99 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 =E2=80=98--directories=3Drecurse=E2=80=99 opti= on. =E2=80=98-R=E2=80=99 =E2=80=98--dereference-recursive=E2=80=99 For each directory operand, read and process all files in that directory, recursively, following all symbolic links. From unknown Fri Jun 20 20:09:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47649: grep bug report - improper handling of file symlinks with -r option Resent-From: Chris Drake Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Sat, 07 Aug 2021 13:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47649 X-GNU-PR-Package: grep X-GNU-PR-Keywords: To: Jim Meyering Cc: 47649@debbugs.gnu.org Received: via spool by 47649-submit@debbugs.gnu.org id=B47649.162834411321955 (code B ref 47649); Sat, 07 Aug 2021 13:49:02 +0000 Received: (at 47649) by debbugs.gnu.org; 7 Aug 2021 13:48:33 +0000 Received: from localhost ([127.0.0.1]:52185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCMgi-0005hv-Rj for submit@debbugs.gnu.org; Sat, 07 Aug 2021 09:48:33 -0400 Received: from mail-ua1-f45.google.com ([209.85.222.45]:45690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCKjd-0002Ro-ED for 47649@debbugs.gnu.org; Sat, 07 Aug 2021 07:43:27 -0400 Received: by mail-ua1-f45.google.com with SMTP id t26so4795986uao.12 for <47649@debbugs.gnu.org>; Sat, 07 Aug 2021 04:43:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qSNtF6I28M2wE0si180ww7UBDh6cjo4xvi6hJ1no8Qc=; b=K+caFsJ/RDmmsym5OWwrkijIa5XdMDJ4CTc2KPhc4YQU64NXxnRM1u8DY4Dw6UBbrv lwcF4ZBGqJxqyTpmOynb791RTnzPiaElFHpulo01VLmrIykNpYybl13dfuy6VxoafLcj SVhfvk/g2adyr9ckB2ed8xLOP2vxkMIaKMeuDChG5PJ8PDdws5qlcJoztCj3Rtl2Yooh 3fN6is7O8KkyLRq+yhs35HTggwsGT2R7dQ+/UyIc88BZ7EtAAPn+0wT06IT8JNOvNmet /qUg63U9pkv+jf1TBSN+5vwsR9X50sR377HnZ8I/snk9Df/qFk+Wp8yAWr2RUk0+Glsd /lKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qSNtF6I28M2wE0si180ww7UBDh6cjo4xvi6hJ1no8Qc=; b=JTSz4skeHGrcH7IcNVEZIOzViCji/aoKYYKuxUaIB8s5YKQxEU/V9a9szRa2CcY+6K 56/SaVjiJVJj9d5kw3FWJ1oMUPETVTeTV2pAc1qEPd69XiKO/FnFY4NTskf2/8xHHQ3R KidUStPkY0T/cOr6kcdkPM3zSRV4mLMgKVjkR8SdXICAmQtm516+oc2Jwsm9tsL18j/m 0o9d4dsYIItAja3QtFnB3MlkN5OYOIQI15QKuSJ/2Lfwy4iTkYVK2brLcIiLHShWZKna pGqIIasKt/17Gc+twmcLFbsn9TxzipW2sb0BmnnVZcbhqJIwGyz4Oo1dGuMyteqQz/2T g8aQ== X-Gm-Message-State: AOAM532kk47iGS0q66+10T+fa4mJeIGjhD35sgxmzpy6TREP1Huh3Bvi 0e7SteFhGKoAwnQXZ0yFfmVNRBMPr+gqXCYez9OpMSE/bGY= X-Google-Smtp-Source: ABdhPJw0NQvBzul1SMFBvPGUf8NWXPnhCQCPp5Xmt2o23CmklzRf7AGKhoPjP0GtAWFjcN7hhHaTtwcq9fW+Dy51lFE= X-Received: by 2002:ab0:23c8:: with SMTP id c8mr11606242uan.49.1628336599798; Sat, 07 Aug 2021 04:43:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Chris Drake Date: Sat, 7 Aug 2021 21:43:08 +1000 Message-ID: Content-Type: multipart/alternative; boundary="0000000000009b182f05c8f6a8ec" X-Spam-Score: 0.0 (/) X-Mailman-Approved-At: Sat, 07 Aug 2021 09:48:26 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000009b182f05c8f6a8ec Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 wrote: > tags 47649 notabug > close 47649 > done > > On Wed, Apr 7, 2021 at 7:21 PM Chris Drake wrote: > > *This is the original working grep behaviour - it found text inside fil= es > > 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: > > =E2=80=98-r=E2=80=99 > =E2=80=98--recursive=E2=80=99 > 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 =E2=80=98--directories=3Drecurse=E2=80=99 op= tion. > > =E2=80=98-R=E2=80=99 > =E2=80=98--dereference-recursive=E2=80=99 > For each directory operand, read and process all files in that > directory, recursively, following all symbolic links. > --0000000000009b182f05c8f6a8ec Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi=C2=A0Jim,

Looks like the -r and -R g= ot mixed up?

What is now the "-R" behave= s the same way as the original "-r", and now the new "-r&quo= t; behaves differently.

For backwards-compatibilit= y, the original behaviour should have been preserved, and the new feature a= ssigned to a new switch ?

On Sat, Aug 7, 2021 at 3:10 PM Jim Meyering = <jim@meyering.net> wrote:
=
tags 47649 notabug<= br> 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 fi= les
> 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 PUR= POSE.
>
> [root@ir2 ~]# mkdir bugdemo
> [root@ir2 ~]# cd bugdemo
> [root@ir2 bugdemo]# echo "this is my test file" > testfil= e1
> [root@ir2 bugdemo]# echo "this is my test file" > testfil= e2
> [root@ir2 bugdemo]# mkdir folder
> [root@ir2 bugdemo]# cd folder
> [root@ir2 folder]# echo "this is my test file" > testfile= 3
> [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, an= d
> 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:

=E2=80=98-r=E2=80=99
=E2=80=98--recursive=E2=80=99
=C2=A0 =C2=A0 =C2=A0For each directory operand, read and process all files = in that
=C2=A0 =C2=A0 =C2=A0directory, recursively.=C2=A0 Follow symbolic links on = the command line,
=C2=A0 =C2=A0 =C2=A0but skip symlinks that are encountered recursively.=C2= =A0 Note that if
=C2=A0 =C2=A0 =C2=A0no file operand is given, grep searches the working dir= ectory.
=C2=A0 =C2=A0 =C2=A0This is the same as the =E2=80=98--directories=3Drecurs= e=E2=80=99 option.

=E2=80=98-R=E2=80=99
=E2=80=98--dereference-recursive=E2=80=99
=C2=A0 =C2=A0 =C2=A0For each directory operand, read and process all files = in that
=C2=A0 =C2=A0 =C2=A0directory, recursively, following all symbolic links.
--0000000000009b182f05c8f6a8ec-- From unknown Fri Jun 20 20:09:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47649: grep bug report - improper handling of file symlinks with -r option Resent-From: Jim Meyering Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Sat, 07 Aug 2021 18:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47649 X-GNU-PR-Package: grep X-GNU-PR-Keywords: To: Chris Drake Cc: 47649@debbugs.gnu.org Received: via spool by 47649-submit@debbugs.gnu.org id=B47649.162836036416975 (code B ref 47649); Sat, 07 Aug 2021 18:20:02 +0000 Received: (at 47649) by debbugs.gnu.org; 7 Aug 2021 18:19:24 +0000 Received: from localhost ([127.0.0.1]:53125 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCQup-0004Pj-TP for submit@debbugs.gnu.org; Sat, 07 Aug 2021 14:19:24 -0400 Received: from mail-wm1-f44.google.com ([209.85.128.44]:43902) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCQuo-0004PV-35 for 47649@debbugs.gnu.org; Sat, 07 Aug 2021 14:19:23 -0400 Received: by mail-wm1-f44.google.com with SMTP id l8-20020a05600c1d08b02902b5acf7d8b5so7680375wms.2 for <47649@debbugs.gnu.org>; Sat, 07 Aug 2021 11:19:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jZKsFi3/AWCOvwNcCDL12oI4nzjNJxH5L20dxu5ZMps=; b=Bqo8L/cWXCM42aex6CcY2D53i71a9JVX1o70ru71qkTquC0wmQvwekO4vs6+C4zR9/ 7XOzX6pgRY57zyyst6/haLUk54+POKHd+V71eOQCsjcWVpyjn7whuUVYQdnSzZOViLbe kCHOREIWvvvrKjgwL33hxsRJnIrXoCB+iCNLSXZVlb91feVEldRDGCDGsY9jgxU5S9vY Mrj8spebrDJaEg94f3EFI1Pah5Co8wBdeMzXfGNvr7AmlgFbKtpQw49//X29o8poKnYE GPK3XMlTaHTJx6V7pOUa0TaEspnG7hTQCqRGu8hB4uwwNkhdLhvo39ttPCR4tYE9hYUr RDFg== X-Gm-Message-State: AOAM5326UI322VvIaQ/tDjTRTKbsKQseEeR85TfLz3gZjhygkdcQXkLg B4WLZnbV4QlyofpBSWo7YMXn27rQvPLDqKUFCLA= X-Google-Smtp-Source: ABdhPJz2SokdDJjLFoWzYpgp+rckQg1VCp3ShIf46rwc19uLd0OyC7TkbihO66gBJgJM4MT8B/xEW/bC6svL+CPQ+Eo= X-Received: by 2002:a7b:c0c1:: with SMTP id s1mr8873074wmh.130.1628360356218; Sat, 07 Aug 2021 11:19:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jim Meyering Date: Sat, 7 Aug 2021 11:19:04 -0700 Message-ID: Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On Sat, Aug 7, 2021 at 4:43 AM Chris Drake wrote: > 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 ? Hi Chris, There was no mix-up, and this is not new. This was a deliberate decision that dates back to 2012 (first release with it was 2.12). Sorry this causes you difficulty, but at least one other grep implementation has -r and -R options that work this way: https://www.freebsd.org/cgi/man.cgi?query=grep From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 09 06:38:13 2021 Received: (at control) by debbugs.gnu.org; 9 Aug 2021 10:38:13 +0000 Received: from localhost ([127.0.0.1]:55921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mD2fd-00035Y-AY for submit@debbugs.gnu.org; Mon, 09 Aug 2021 06:38:13 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:52692) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mD2fY-00035F-Gj for control@debbugs.gnu.org; Mon, 09 Aug 2021 06:38:12 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D44691600EF for ; Mon, 9 Aug 2021 03:38:02 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id qkm76h098Poo for ; Mon, 9 Aug 2021 03:38:02 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 490FA1600F3 for ; Mon, 9 Aug 2021 03:38:02 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id IU0aID7fty-a for ; Mon, 9 Aug 2021 03:38:02 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 2C55F1600EF for ; Mon, 9 Aug 2021 03:38:02 -0700 (PDT) To: control@debbugs.gnu.org From: Paul Eggert Subject: close 47649 Organization: UCLA Computer Science Department Message-ID: <472e3ef1-da49-5b86-3d5b-e28ff2188898@cs.ucla.edu> Date: Mon, 9 Aug 2021 03:38:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 47649 thanks Jim tried to close this in his email but it didn't take.