Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
CandyWater 2026-02-22 04:06:02 +08:00 committed by GitHub
parent 0da00072ef
commit 790ac92c7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -110,7 +110,12 @@ func NewExecToolWithConfig(workingDir string, restrict bool, config *config.Conf
if len(allowPatterns) > 0 {
allowRegex = make([]*regexp.Regexp, 0, len(allowPatterns))
for _, p := range allowPatterns {
allowRegex = append(allowRegex, regexp.MustCompile(p))
re, err := regexp.Compile(p)
if err != nil {
fmt.Fprintf(os.Stderr, "NewExecTool: invalid allow pattern %q: %v\n", p, err)
continue
}
allowRegex = append(allowRegex, re)
}
}