"grep -rI ... /" vs. processing of /dev/ : should "--exclude-dir /dev" be required in order to avoid /dev/?

Kyle Evans kevans at freebsd.org
Wed Feb 17 19:44:59 UTC 2021


On Tue, Feb 16, 2021 at 7:29 PM Kyle Evans <kevans at freebsd.org> wrote:
>
> On Tue, Feb 16, 2021 at 7:23 PM Mark Millard via freebsd-current
> <freebsd-current at freebsd.org> wrote:
> >
> > I historically on occasion have done something like:
> >
> > # grep -rI ... /
> >
> > in order to find all instances of a text, including
> > in build trees and such. I now find that I need to
> > do something more like (using a more specific
> > example):
> >
> > # grep -rI --exclude-dir /dev '#define.*__FreeBSD_version'
> >
> > otherwise the grep ends up reading from the tty and waits
> > for it. Top shows, for example,
> >
> > 13470 root         22    0  12848Ki    2692Ki ttyin   11   0:00   0.00% grep -rI #define.*__FreeBSD_version /
> >
> > Is this expected? Should I have always been using
> > "--exclude-dir /dev"? What lead to the behavior
> > change?
> >
>
> I can't seem to find any evidence that gnugrep in base handled this
> any differently. Experimentation seems to reveal that modern gnugrep
> will skip devices unless they're explicitly named for searching
> (unless supplied a different --devices option), which does feel like a
> good idea.

Here's my proposal: https://people.freebsd.org/~kevans/grep-rdev.diff


More information about the freebsd-current mailing list