From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 12 11:37:53 2014 Received: (at submit) by debbugs.gnu.org; 12 Jun 2014 15:37:53 +0000 Received: from localhost ([127.0.0.1]:45773 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wv74W-0006qE-UH for submit@debbugs.gnu.org; Thu, 12 Jun 2014 11:37:52 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45750) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wv3lx-0008Qj-7Z for submit@debbugs.gnu.org; Thu, 12 Jun 2014 08:06:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wv3ll-0000gP-7c for submit@debbugs.gnu.org; Thu, 12 Jun 2014 08:06:19 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:33423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wv3ll-0000gJ-4t for submit@debbugs.gnu.org; Thu, 12 Jun 2014 08:06:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wv3lf-0002TO-4z for bug-grep@gnu.org; Thu, 12 Jun 2014 08:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wv3lY-0000a9-3H for bug-grep@gnu.org; Thu, 12 Jun 2014 08:06:06 -0400 Received: from parmail03.iap.socgen.com ([207.45.249.187]:35690) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wv3lX-0000YD-Ha for bug-grep@gnu.org; Thu, 12 Jun 2014 08:06:00 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,464,1400018400"; d="scan'208,217";a="231037969" From: ANDREUX Hugues To: "bug-grep@gnu.org" Subject: grep --exclude does not match files as documented in man page Thread-Topic: grep --exclude does not match files as documented in man page Thread-Index: Ac+GNqh3ieQnMnNdTI6OWxbeOs+NoA== Date: Thu, 12 Jun 2014 12:05:52 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [175.0.0.26] Content-Type: multipart/alternative; boundary="_000_D19AB641DF68BF49AC776A299B8A067E044676MMXDC2641hermessi_" MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 12 Jun 2014 11:37:46 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -5.0 (-----) --_000_D19AB641DF68BF49AC776A299B8A067E044676MMXDC2641hermessi_ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable It seems file globbing as done by 'grep --exclude' is broken when wildcards= are used. $ echo foo >bar $ grep --exclude=3D'.*' . ./bar $ grep --exclude=3D'.*' . bar foo Expected behavior: grep -exclude should not exclude bar, whether it is pref= ixed by ./ or not. According to the man page: " --exclude=3DGLOB Skip files whose *base name* matches GLOB (using wildcard mat= ching). [...]" This behavior seems to only occur with whenever a directory component of th= e file path matches the GLOB, e.g.: $ grep --exclude '.*' . ../bar $ grep --exclude '.*' . .../bar $ grep --exclude '.*' . .TEST/bar $ grep --exclude '.*' . hugues/.TEST/bar The bug triggers with other globs, unless there is no wildcard: $ grep --exclude 'w*' . work/bar $ grep --exclude 'work' . work/bar foo Regards, Hugues Andreux ************************************************************************* This message and any attachments (the "message") are confidential, intended= solely for the addressee(s), and may contain legally privileged informatio= n. Any unauthorised use or dissemination is prohibited. E-mails are susceptibl= e to alteration. = Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates shall be= liable for the message if altered, changed or falsified. Please visit http://swapdisclosure.sgcib.com for important information with= respect to derivative products. ************ Ce message et toutes les pieces jointes (ci-apres le "message") sont confid= entiels et susceptibles de contenir des informations couvertes = par le secret professionnel. = Ce message est etabli a l'intention exclusive de ses destinataires. Toute u= tilisation ou diffusion non autorisee est interdite. Tout message electronique est susceptible d'alteration. = La SOCIETE GENERALE et ses filiales declinent toute responsabilite au titre= de ce message s'il a ete altere, deforme ou falsifie. Veuillez consulter le site http://swapdisclosure.sgcib.com afin de recueill= ir d'importantes informations sur les produits derives. ************************************************************************* --_000_D19AB641DF68BF49AC776A299B8A067E044676MMXDC2641hermessi_ Content-Type: text/html; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable

It seems file globbing as done = by ‘grep --exclude’ is broken when wildcards are used.

 

$ echo foo >bar

$ grep --exclude=3D'.*' . ./bar=

$ grep --exclude=3D'.*' . bar

foo

 

Expected behavior: grep –= exclude should not exclude bar, whether it is prefixed by ./ or not. Accord= ing to the man page:

“    =    --exclude=3DGLOB

     &= nbsp;        Skip files whose *base n= ame* matches GLOB (using wildcard matching). […]”

 

This behavior seems to only occ= ur with whenever a directory component of the file path matches the GLOB, e= .g.:

$ grep --exclude '.*' . ../bar<= o:p>

$ grep --exclude '.*' . .../bar=

$ grep --exclude '.*' . .TEST/b= ar

$ grep --exclude '.*' . hugues/= .TEST/bar

 

The bug triggers with other glo= bs, unless there is no wildcard:

$ grep --exclude 'w*' . work/ba= r

$ grep --exclude 'work' . work/= bar

foo

 

Regards,

 

Hugues Andreux

************************************************************************= *
This message and any attachments (the "message") are confidential, int= ended solely for the addressee(s), and may contain legally privileged infor= mation.
Any unauthorised use or dissemination is prohibited. E-mails are= susceptible to alteration. 
Neither SOCIETE GENERALE nor any of i= ts subsidiaries or affiliates shall be liable for the message if altered, c= hanged or
falsified.
Please visit http://swapdisclosure.sgcib.com for= important information with respect to derivative products.
   = ;                     &nb= sp;     ************
Ce message et toutes les pieces jointes (= ci-apres le "message") sont confidentiels et susceptibles de contenir des i= nformations couvertes
par le secret professionnel.
Ce message est e= tabli a l'intention exclusive de ses destinataires. Toute utilisation ou di= ffusion non autorisee est interdite.
Tout message electronique est susce= ptible d'alteration.
La SOCIETE GENERALE et ses filiales declinent tout= e responsabilite au titre de ce message s'il a ete altere, deforme ou falsi= fie.
Veuillez consulter le site http://swapdisclosure.sgcib.com afin de = recueillir d'importantes informations sur les produits derives.
********= *****************************************************************

--_000_D19AB641DF68BF49AC776A299B8A067E044676MMXDC2641hermessi_-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 11 16:24:14 2014 Received: (at 17763-done) by debbugs.gnu.org; 11 Jul 2014 20:24:14 +0000 Received: from localhost ([127.0.0.1]:53754 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X5hMb-00060n-B6 for submit@debbugs.gnu.org; Fri, 11 Jul 2014 16:24:14 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:40591) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X5hMV-0005yk-1p for 17763-done@debbugs.gnu.org; Fri, 11 Jul 2014 16:24:11 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 024D0A60006; Fri, 11 Jul 2014 13:24:01 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XVz7Ui0PAoPO; Fri, 11 Jul 2014 13:23:56 -0700 (PDT) Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 8FB4839E8013; Fri, 11 Jul 2014 13:23:56 -0700 (PDT) Message-ID: <53C047DC.5070203@cs.ucla.edu> Date: Fri, 11 Jul 2014 13:23:56 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: ANDREUX Hugues , 17763-done@debbugs.gnu.org Subject: Re: bug#17763: grep --exclude does not match files as documented in man page References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------000101000809080006090504" X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 17763-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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.0 (---) This is a multi-part message in MIME format. --------------000101000809080006090504 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 06/12/2014 05:05 AM, ANDREUX Hugues wrote: > According to the man page: > " --exclude=GLOB > Skip files whose*base name* matches GLOB (using wildcard matching). Thanks, I think that's a bug in the documentation, not in the code; grep's behavior is similar to that of tar's, which has similar options. I installed the attached documentation patch. --------------000101000809080006090504 Content-Type: text/x-patch; name="0001-doc-Document-r-vs-exclude-more-carefully.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-doc-Document-r-vs-exclude-more-carefully.patch" >From a279045bf933f45f2c78fd424ef832b688920a40 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 11 Jul 2014 13:21:19 -0700 Subject: [PATCH] doc: Document -r vs --exclude more carefully. Problem reported by Hugues Andreux in: http://bugs.gnu.org/17763 * doc/grep.texi (File and Directory Selection): Be more careful about documenting the interaction between recursive searching, --include, --exclude, and --exclude-dir. --- doc/grep.texi | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/grep.texi b/doc/grep.texi index 6c484d6..0115560 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -651,9 +651,10 @@ this is equivalent to the @option{-r} option. @opindex --exclude @cindex exclude files @cindex searching directory trees -Skip files whose base name matches @var{glob} -(using wildcard matching). -A file-name glob can use +Skip files whose name matches the pattern @var{glob}, using wildcard +matching. When searching recursively, skip any subfile whose base +name matches @var{glob}; the base name is the part after the last +@samp{/}. A pattern can use @samp{*}, @samp{?}, and @samp{[}...@samp{]} as wildcards, and @code{\} to quote a wildcard or backslash character literally. @@ -661,15 +662,16 @@ and @code{\} to quote a wildcard or backslash character literally. @opindex --exclude-from @cindex exclude files @cindex searching directory trees -Skip files whose base name matches any of the file-name globs +Skip files whose name matches any of the patterns read from @var{file} (using wildcard matching as described under @option{--exclude}). -@item --exclude-dir=@var{dir} +@item --exclude-dir=@var{glob} @opindex --exclude-dir @cindex exclude directories -Skip any directory whose name matches the pattern @var{dir}, ignoring -any redundant trailing slashes in @var{dir}. +Skip any directory whose name matches the pattern @var{glob}. When +searching recursively, skip any subdirectory whose base name matches +@var{glob}. Ignore any redundant trailing slashes in @var{glob}. @item -I Process a binary file as if it did not contain matching data; @@ -679,8 +681,8 @@ this is equivalent to the @samp{--binary-files=without-match} option. @opindex --include @cindex include files @cindex searching directory trees -Search only files whose base name matches @var{glob} -(using wildcard matching as described under @option{--exclude}). +Search only files whose name matches @var{glob}, +using wildcard matching as described under @option{--exclude}. @item -r @itemx --recursive -- 1.9.3 --------------000101000809080006090504-- From unknown Sat Jun 21 05:08:20 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 09 Aug 2014 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator