bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#33699: Multi-component paths ignored by --{exclude, include}-dir ?


From: Jim Meyering
Subject: bug#33699: Multi-component paths ignored by --{exclude, include}-dir ?
Date: Sat, 15 Dec 2018 11:12:48 -0800

tags 33699 notabug
close 33699
stop

On Mon, Dec 10, 2018 at 5:29 PM Lyude Paul <address@hidden> wrote:
> Oh whoops, almost forgot to mention the version of grep I'm using:
> grep-3.1-8.fc29 on Fedora 29
>
> I've also checked through the source files for Fedora's grep package, and
> confirmed there's no patches getting applied that would modify the behavior of
> --exclude and friends.
>
> On Mon, 2018-12-10 at 18:48 -0500, Lyude Paul wrote:
> > Hi! Sorry for bugging you, but I noticed something a little peculiar about
> > grep that I wasn't expecting, and I'm not sure if this is a bug or not.
> > I've been trying to use grep in one of my scripts to exclude files from
> > any directories starting with Documentation/output using --exclude-dir.
> > Example:
> >
> > grep vcpi_ . -rl --exclude-dir Documentation/output
> >
> > However, this doesn't seem to work at all as it returns:
> >
> > ./Module.symvers
> > ./drivers/gpu/drm/radeon/radeon_dp_mst.c
> > ./drivers/gpu/drm/drm_dp_mst_topology.c
> > ./drivers/gpu/drm/nouveau/dispnv50/disp.c
> > ./drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c
> > ./drivers/gpu/drm/nouveau/include/nvif/cl5070.h
> > ./drivers/gpu/drm/Module.symvers
> > ./drivers/gpu/drm/i915/intel_dp_mst.c
> > ./drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> > ./include/drm/drm_dp_mst_helper.h
> > ./Documentation/output/gpu/drm-kms-helpers.html
> > ./Documentation/output/gpu/drm-dp-mst-helpers.html
> > ./Documentation/output/gpu/dp-mst.html
> > ./Documentation/output/genindex.html
> > ./Documentation/output/latex/gpu.aux
> > ./Documentation/output/latex/gpu.tex
> > ./Documentation/output/searchindex.js

Thanks for the report. However you are searching recursively, so when
the manual says this:

       --exclude-dir=GLOB
              ... When searching  recursively, skip any subdirectory
whose base name matches GLOB.  Ignore any redundant trailing slashes
in GLOB.

it means that a nontrivial GLOB containing a slash will never match,
since the only base name that can contain a slash is the degenerate
one: "/".

> > I would have thought maybe this could be worked around by using
> > --exclude instead:
> >
> > grep vcpi_ . -rl --exclude '.*Documentation/output.*'

You've specified what looks like regular expression, with ".*" at
front and back. this option takes a GLOB, not a regular expression.
And as above, when recursive, the GLOB cannot usefully contain a
slash.

As such, I'm closing this as not-a-bug.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]