Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Feb 2021 14:26:37 -0800
From:      Mark Millard <marklmi@yahoo.com>
To:        Kyle Evans <kevans@freebsd.org>
Cc:        freebsd-current <freebsd-current@freebsd.org>
Subject:   Re: "grep -rI ... /" vs. processing of /dev/ : should "--exclude-dir /dev" be required in order to avoid /dev/?
Message-ID:  <AC3EA5C1-BEF1-4CE9-8AAC-45E83C051888@yahoo.com>
In-Reply-To: <CACNAnaE1g1vAeq1yw5_KjfQ%2BjgCFCgTXOGBh-K4ggKSra-cctw@mail.gmail.com>
References:  <B822DED7-0607-47F3-8C1F-4C814D2A9EF5.ref@yahoo.com> <B822DED7-0607-47F3-8C1F-4C814D2A9EF5@yahoo.com> <CACNAnaES4r3bMjhzTz_qMh5SGVypFuF%2BrSkDHc00xczFjK73vg@mail.gmail.com> <CACNAnaE1g1vAeq1yw5_KjfQ%2BjgCFCgTXOGBh-K4ggKSra-cctw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2021-Feb-17, at 11:44, Kyle Evans <kevans at freebsd.org> wrote:

> On Tue, Feb 16, 2021 at 7:29 PM Kyle Evans <kevans at freebsd.org> =
wrote:
>>=20
>> On Tue, Feb 16, 2021 at 7:23 PM Mark Millard via freebsd-current
>> <freebsd-current@freebsd.org> wrote:
>>>=20
>>> I historically on occasion have done something like:
>>>=20
>>> # grep -rI ... /
>>>=20
>>> 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):
>>>=20
>>> # grep -rI --exclude-dir /dev '#define.*__FreeBSD_version'
>>>=20
>>> otherwise the grep ends up reading from the tty and waits
>>> for it. Top shows, for example,
>>>=20
>>> 13470 root         22    0  12848Ki    2692Ki ttyin   11   0:00   =
0.00% grep -rI #define.*__FreeBSD_version /
>>>=20
>>> Is this expected? Should I have always been using
>>> "--exclude-dir /dev"? What lead to the behavior
>>> change?
>>>=20
>>=20
>> 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.
>=20
> Here's my proposal: https://people.freebsd.org/~kevans/grep-rdev.diff

wget, git apply, buildworld, installworld, and some quick testing:

Seems to work as described in the updated man page and avoids my
needing "--exclude-dir /dev" (or other alternatives) by default
with the -r .

I did try some explicit /dev and /dev/tty and /dev/random use,
and some "no -r" variations of the -r testing. While it was
just quick testing, I did not notice anything odd happening.
I did do one -r for / that I let run to completion.



FYI: this is based on main 3acea07c1873 as a context. In
more detail:

# ~/fbsd-based-on-what-freebsd-main.sh=20
merge-base: 3acea07c1873b1e4042f4a4fa8668745ee59f15b
merge-base: CommitDate: 2021-02-08 19:15:21 +0000
c1845d00f818 (HEAD -> mm-src) mm-src snapshot for mm's patched build in =
git context.
3acea07c1873 (pure-src) Restore the augmented strlen commentary
FreeBSD FBSDFHUGE 14.0-CURRENT FreeBSD 14.0-CURRENT =
mm-src-n244686-c1845d00f818 GENERIC-NODBG  amd64 amd64 1400004 1400004


=3D=3D=3D
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AC3EA5C1-BEF1-4CE9-8AAC-45E83C051888>