Skip to content

Commit

Permalink
✨ Use perl regexes to improve special char handling (#383)
Browse files Browse the repository at this point in the history
The `-E` option in `grep` won't properly handle things like `\n` or
`\t`. Using perl regexes fixes the problem.

Current success rate improves marginally, from 68.72% to 68.92%.

Signed-off-by: Juan Manuel Leflet Estrada <[email protected]>
  • Loading branch information
jmle committed Oct 20, 2023
1 parent 6b0dfac commit ec501b3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion provider/internal/builtin/service_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (p *builtinServiceClient) Evaluate(ctx context.Context, cap string, conditi
return response, fmt.Errorf("could not parse provided regex pattern as string: %v", conditionInfo)
}
var outputBytes []byte
grep := exec.Command("grep", "-o", "-n", "-R", "-E", c.Pattern, p.config.Location)
grep := exec.Command("grep", "-o", "-n", "-R", "-P", c.Pattern, p.config.Location)
outputBytes, err := grep.Output()
if err != nil {
if exitError, ok := err.(*exec.ExitError); ok && exitError.ExitCode() == 1 {
Expand Down

0 comments on commit ec501b3

Please sign in to comment.