-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Allow case-insensitive filename globbing; add nocaseglob #1073
Conversation
Can you give some context in terms of when is this useful for a shell? I see |
I have an terminal/shell app that uses this package as its shell interpreter. It also, as mentioned in this PR, uses expand.Fields to do filename expansion, like bash does when you press tab. So I'd like c to expand to both "cmd" and "CHANGELOG.md". My app translates "c" to "c*" and calls expand.Fields. This is similar to if you set Would you like me to add the "nocaseglob" shopt and make it set this flag? |
OK gotcha, makes sense. If you want to wire it up to the interpreter that would be nice as a way to make this change a bit more well rounded and get the easy win, but it's not a must. I'll review later. |
- Add a FoldCase flag to the expand.Config struct, which is used to configure how expand.Fields behaves. - Similarly, add a FoldCase Mode to pattern.Regexp. Setting the flag adds (?i) to the front of the generated regular expression. - Use the former to set the latter when calling expand.Fields. - Use all of the above to implement the "nocaseglob" shopt. Rationale: I use expand.Fields to do filename expansion, for which I'd like to do case-insensitive matching. E.g. I'd like "c*" to match both "cmd" and "CHANGELOG.md"
I added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Appreciate the added comments too.
Rationale: I use expand.Fields to do filename expansion, for which I'd like to do case-insensitive matching. E.g. I'd like "c*" to match both "cmd" and "CHANGELOG.md"