GNU bug report logs - #17763
grep --exclude does not match files as documented in man page

Previous Next

Package: grep;

Reported by: ANDREUX Hugues <hugues.andreux <at> sgcib.com>

Date: Thu, 12 Jun 2014 15:38:03 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: ANDREUX Hugues <hugues.andreux <at> sgcib.com>
Subject: bug#17763: closed (Re: bug#17763: grep --exclude does not match
 files as documented in man page)
Date: Fri, 11 Jul 2014 20:25:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#17763: grep --exclude does not match files as documented in man page

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 17763 <at> debbugs.gnu.org.

-- 
17763: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17763
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: ANDREUX Hugues <hugues.andreux <at> sgcib.com>, 
 17763-done <at> debbugs.gnu.org
Subject: Re: bug#17763: grep --exclude does not match files as documented
 in man page
Date: Fri, 11 Jul 2014 13:23:56 -0700
[Message part 3 (text/plain, inline)]
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.
[0001-doc-Document-r-vs-exclude-more-carefully.patch (text/x-patch, attachment)]
[Message part 5 (message/rfc822, inline)]
From: ANDREUX Hugues <hugues.andreux <at> sgcib.com>
To: "bug-grep <at> gnu.org" <bug-grep <at> gnu.org>
Subject: grep --exclude does not match files as documented in man page
Date: Thu, 12 Jun 2014 12:05:52 +0000
[Message part 6 (text/plain, inline)]
It seems file globbing as done by 'grep --exclude' is broken when wildcards are used.

$ echo foo >bar
$ grep --exclude='.*' . ./bar
$ grep --exclude='.*' . bar
foo

Expected behavior: grep -exclude should not exclude bar, whether it is prefixed by ./ or not. According to the man page:
"       --exclude=GLOB
              Skip files whose *base name* matches GLOB (using wildcard matching). [...]"

This behavior seems to only occur with whenever a directory component of the 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 information.
Any unauthorised use or dissemination is prohibited. E-mails are susceptible 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 confidentiels et susceptibles de contenir des informations couvertes 
par le secret professionnel. 
Ce message est etabli a l'intention exclusive de ses destinataires. Toute utilisation 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 recueillir d'importantes informations sur les produits derives.
*************************************************************************
[Message part 7 (text/html, inline)]

This bug report was last modified 10 years and 318 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.