PerlPowerTools
PerlPowerTools copied to clipboard
grep -F: regex error when pattern includes '/'
- grep -F is not supposed to use regex at all, but in the perl version it does
- I have a file "01" containing the pattern 'a/b' on line 3
- System grep (gnu) has no problem searching for this pattern, but perl grep chokes
- From the error it appears the '/b' part of the pattern is terminating a regex
%grep -Fn 'a/b' 01
3: /test/a/b/c
%perl grep -Fn 'a/b' 01
Unknown regexp modifier "/b" at (eval 1) line 1, at end of line
syntax error at (eval 1) line 1, at EOF
...propagated at grep line 261.
Okay, this is really twisted code. There is stuff all over the program to affect the pattern and some of them aren't guarded.
I think most of this code needs to be rewritten and restructured:
- with -F seen, don't go through any of the pattern adjustment stuff.
- break up the parse_args into smaller bits.
- potentially create a completely different sort of matcher when -F is called so no regex stuff is there.
- Recent commits to grep have added support for real fixed-string search without invoking regex engine.
- Now I can search for things like a single slash... grep -Fn '/' yourfile.awk
- This issue could be closed now