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

grep: fix regression for -F search #633

Merged
merged 1 commit into from
Jun 2, 2024
Merged

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Jun 2, 2024

  • The following search should match, but did not because of the '#' character: perl grep -F '#include' a.c
  • This was because quotemeta() was escaping it as \# which was then expanded between single quotes
  • The $matcher closure can refer to patterns list directly; this avoids having to expand pattern strings within quotes
  • This version is easier to follow because duplicate statements are not added to the closure code if many patterns are specified
%perl head -n1 a.c
#include <stdio.h>
%perl grep -F '#include' a.c
#include <stdio.h>
%perl grep -Fi '#includE' a.c
#include <stdio.h>

* The following search should match, but did not because of the '#' character: perl grep -F '#include' a.c
* This was because quotemeta() was escaping it as \# which was then expanded between single quotes
* The $matcher closure can refer to patterns list directly, which removes the need for pattern strings to be expanded with quotes
* This version is easier to follow because duplicate statements are not added to the closure code if many patterns are used
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: grep The grep program labels Jun 2, 2024
@briandfoy briandfoy self-assigned this Jun 2, 2024
@briandfoy
Copy link
Owner

changes: be more careful with quotemeta and patterns

@briandfoy briandfoy merged commit 26d0db3 into briandfoy:master Jun 2, 2024
2 checks passed
@briandfoy briandfoy added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: grep The grep program Status: accepted The fix is accepted Type: enhancement improve a feature that already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants