GNU bug report logs - #22144
--exclude no longer works against arguments with a directory name

Previous Next

Package: grep;

Reported by: Vincent Lefevre <vincent <at> vinc17.net>

Date: Fri, 11 Dec 2015 18:38:02 UTC

Severity: normal

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

Bug is archived. No further changes may be made.

Full log


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

From: Vincent Lefevre <vincent <at> vinc17.net>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 22144 <at> debbugs.gnu.org
Subject: Re: bug#22144: --exclude no longer works against arguments with a
 directory name
Date: Sat, 12 Dec 2015 02:56:34 +0100
On 2015-12-11 13:37:46 -0800, Paul Eggert wrote:
> The change in grep 2.22 is due to an earlier bug report:
> 
> http://bugs.gnu.org/21027

This one was about --exclude-dir, whose description in grep 2.21 is
very unclear and it was already broken anyway:

zira:~> grep -rl e --exclude-dir='usr*' /usr/include
zira:~> grep -rl e --exclude-dir='usr*' /usr/include/stdio.h
/usr/include/stdio.h

But for --exclude, the description is clear:

    --exclude=GLOB
        Skip files whose base name matches GLOB (using wildcard
                         ^^^^^^^^^
        matching).  A file-name glob can use *,  ?,  and  [...]
        as  wildcards,  and  \ to quote a wildcard or backslash
        character literally.

"base name" means base name, not the full path!

I suggest that you revert the behavior for --exclude so that existing
scripts are not broken, and possibly add --exclude-path to match the
full path.

Now, --exclude was already broken:

$ grep -l . /usr/share/doc/grep/*
/usr/share/doc/grep/AUTHORS
/usr/share/doc/grep/NEWS.gz
/usr/share/doc/grep/README
/usr/share/doc/grep/THANKS.gz
/usr/share/doc/grep/TODO.gz
/usr/share/doc/grep/changelog.Debian.gz
/usr/share/doc/grep/changelog.gz
/usr/share/doc/grep/copyright

$ grep -l --exclude='*e*' . /usr/share/doc/grep/*

outputs nothing, while one should get:

/usr/share/doc/grep/AUTHORS
/usr/share/doc/grep/NEWS.gz
/usr/share/doc/grep/README
/usr/share/doc/grep/THANKS.gz
/usr/share/doc/grep/TODO.gz
/usr/share/doc/grep/copyright

excluding files whose base name contains a letter "e".

And with grep 2.22, this is still inconsistent:

ypig:~> grep -l --exclude=AUTHORS . /usr/share/doc/grep/*
/usr/share/doc/grep/AUTHORS
/usr/share/doc/grep/NEWS.gz
/usr/share/doc/grep/README
/usr/share/doc/grep/THANKS.gz
/usr/share/doc/grep/TODO.gz
/usr/share/doc/grep/changelog.Debian.gz
/usr/share/doc/grep/changelog.gz
/usr/share/doc/grep/copyright

ypig:~> grep -rl --exclude=AUTHORS . /usr/share/doc/grep
/usr/share/doc/grep/TODO.gz
/usr/share/doc/grep/changelog.gz
/usr/share/doc/grep/changelog.Debian.gz
/usr/share/doc/grep/THANKS.gz
/usr/share/doc/grep/NEWS.gz
/usr/share/doc/grep/copyright
/usr/share/doc/grep/README

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




This bug report was last modified 9 years and 140 days ago.

Previous Next


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