Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctness issue: pattern doesn't match when it should #1084

Closed
khyperia opened this issue Oct 16, 2018 · 2 comments
Closed

Correctness issue: pattern doesn't match when it should #1084

khyperia opened this issue Oct 16, 2018 · 2 comments
Labels
duplicate An issue that is duplicative of another.

Comments

@khyperia
Copy link

What version of ripgrep are you using?

% rg --version
ripgrep 0.10.0
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)

What operating system are you using ripgrep on?

Arch Linux, using the Arch-official ripgrep package.

Bug description/reproduction steps

This prints out "abcd".

echo 'abcd' | rg 'a(.*(d|ce))'

Adding a "c" makes it not match (i.e. it doesn't print out anything).

echo 'abcd' | rg 'a(.*(cd|ce))'

If this is a bug, what is the expected behavior?

I believe that both regexes should match the input, and print out a match in both cases. Testing using regex101 seems to imply this is true.

Real-world discovery background (non-minimal case that made me discover the minimal repro above):

I was trying to run git diff --name-only master... | rg 'js/src/(.*(cpp|\.h))' --replace '$1'.

git diff --name-only master... printed lines such as:

js/src/frontend/BinSource.yaml
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/ParseNode.h

and I wanted to extract:

frontend/BytecodeEmitter.cpp
frontend/ParseNode.h

(i.e. trim js/src/ off the front, and only match cpp and h files)

However, adding a \. in front of the cpp made nothing match.

git diff --name-only master... | rg 'js/src/(.*(\.cpp|\.h))' --replace '$1' -- prints nothing???

@BurntSushi
Copy link
Owner

This is a duplicate of #1064 and #1081. It's fixed on master.

From my digging, I thought that this bug wasn't a regression, but had always been there in previous versions of ripgrep. However, we've had this bug filed three times since the release of ripgrep 0.10, but never before. So something seems fishy.

@BurntSushi BurntSushi added the duplicate An issue that is duplicative of another. label Oct 16, 2018
@AntCrow
Copy link

AntCrow commented Dec 6, 2018

FWIW, I don't think it's a regression. I found the same thing on 0.8.1, confirmed it on 0.10.0, and was going to report it until I found all the duplicates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate An issue that is duplicative of another.
Projects
None yet
Development

No branches or pull requests

3 participants