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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17763 in the body.
You can then email your comments to 17763 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#17763; Package grep. (Thu, 12 Jun 2014 15:38:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to ANDREUX Hugues <hugues.andreux <at> sgcib.com>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Thu, 12 Jun 2014 15:38:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

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 1 (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 2 (text/html, inline)]

Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Fri, 11 Jul 2014 20:25:02 GMT) Full text and rfc822 format available.

Notification sent to ANDREUX Hugues <hugues.andreux <at> sgcib.com>:
bug acknowledged by developer. (Fri, 11 Jul 2014 20:25:03 GMT) Full text and rfc822 format available.

Message #10 received at 17763-done <at> debbugs.gnu.org (full text, mbox):

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 1 (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)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 09 Aug 2014 11:24:04 GMT) Full text and rfc822 format available.

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.