Skip to content

Conversation

paulhammond
Copy link
Contributor

I was checking your recent changes to how pattern/expand support * and ., and I think there's a mistake in commit ce872e7. The rules that prevent * from matching dots in filenames only apply to the first character. In other words "foo*" should match "foo.suffix". This PR fixes that bug.

@mvdan
Copy link
Owner

mvdan commented Apr 22, 2025

Dang, well spotted.

@mvdan
Copy link
Owner

mvdan commented Apr 22, 2025

I think the same fix needs to happen for foo**, as it effectively behaves like foo*. We might need to refactor the code a bit to allow reusing some of these regex pieces.

The rules that prevent * from matching dots in
filenames only apply to the first character. In
other words "foo*" should match "foo.suffix".
See parent commit for context
@paulhammond
Copy link
Contributor Author

Good point. I just added a followup commit with the naive implementation for ** but you're right that these conditionals are getting pretty complicated. I'll try to take some time to clean it up in the next few days, but if you want to do the work yourself before I get to it I won't mind.

@paulhammond paulhammond changed the title Pattern: allow * to match non-leading dots pattern: allow * to match non-leading dots Apr 22, 2025
@mvdan mvdan merged commit 6ba4a99 into mvdan:master Apr 23, 2025
8 checks passed
@mvdan
Copy link
Owner

mvdan commented Apr 23, 2025

No need, I'll be sending some changes to improve the tests and refactor the code a bit.

@mvdan
Copy link
Owner

mvdan commented Apr 23, 2025

I'm done with those changes as of 93f7ac2. There is no duplication for handling wildcards now, and the highest amount of indentation in that code is down from 7 tabs to 5. The lexer added a bit of verbosity to the code, but I thought it would make the translator a bit more principled and maintainable in the long run.

@paulhammond
Copy link
Contributor Author

Looks good! Thanks again for all the hard work here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants