Re: git grep -E doesn't accept \b word boundaries?
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 3, 2023, 19:35 UTC
- Message-ID
- <xmqq1qjxqkbo.fsf@gitster.g>
- In-Reply-To
- <CAJXgQP1j6JYbtikMuWGFn44+FVb3PfmuwiFrxDGLQAYgr92Wfw@mail.gmail.com>
Kevin Ushey <kevinushey@gmail.com> writes:
Show 18 quoted lines
> I'm seeing the following, which I believe is unexpected. I have a file > with contents: > > $ cat hello.txt > WholeWord > Whole Word > Whole > > I can use `git grep` to search with word boundaries; e.g. > > $ git grep --untracked '\bWhole\b' > hello.txt:Whole Word > hello.txt:Whole > > However, if I add `-E` to use extended regular expressions, the same > invocation finds no search results. > > $ git grep --untracked -E '\bWhole\b'
Does not seem to reproduce for me. In a randomly picked repository (the source to git itself), I did
$ cat >hello.txt
WholeWord
Whole Word
Whole
^Dand "git grep --untracked -E '\bWhole\b' hello.txt" with or without the "-E" option shows the same two lines as hits.
Without the pathspec hello.txt, the output includes one line from unpack-trees.c as well, but the hits from the untracked hello.txt are the same.
The tip of 'master', v2.40.0, v2.38.4, v2.37.4, v2.35.4 (they are by no means significant milestones---just some random versions I picked to test) all behave the same way.