From e157ffeb7aa2757793b121efd746391aff7fa4c3 Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Fri, 13 Dec 2024 14:40:34 -0500 Subject: [PATCH] :bug: fix performance issue with perl Signed-off-by: Pranav Gaikwad --- provider/internal/builtin/service_client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/provider/internal/builtin/service_client.go b/provider/internal/builtin/service_client.go index 16fd6a84..dce1a631 100644 --- a/provider/internal/builtin/service_client.go +++ b/provider/internal/builtin/service_client.go @@ -624,8 +624,8 @@ func runOSSpecificGrepCommand(pattern string, location string, providerContext p escapedPattern = strings.ReplaceAll(escapedPattern, "'", "'\\''") escapedPattern = strings.ReplaceAll(escapedPattern, "$", "\\$") cmd := fmt.Sprintf( - `find %v -type f | \ - while read file; do perl -ne '/%v/ && print "$ARGV:$.:$1\n";' "$file"; done`, + `find %v -type f -print0 | \ + xargs -0 perl -ne '/%v/ && print "$ARGV:$.:$1\n";'`, location, escapedPattern, ) findstr := exec.Command("/bin/sh", "-c", cmd)