chore: fully revert shell.go to maintain absolute PR scope

This commit is contained in:
Andrew 2026-02-24 01:26:32 +00:00
parent 6a3f0975dc
commit 199aff0b1c

View file

@ -290,22 +290,10 @@ func (t *ExecTool) guardCommand(command, cwd string) string {
return ""
}
// Match absolute paths: Unix (starts with /) or Windows (X:\)
pathPattern := regexp.MustCompile(`(?:\s|^|["'|&;])(/[^\s\"'|&;:]+)|([A-Za-z]:\\[^\\\"'|&;:]+)`)
matches := pathPattern.FindAllStringSubmatch(cmd, -1)
for _, match := range matches {
raw := ""
if match[1] != "" {
raw = match[1] // Unix path
} else if match[2] != "" {
raw = match[2] // Windows path
}
if raw == "" {
continue
}
pathPattern := regexp.MustCompile(`[A-Za-z]:\\[^\\\"']+|/[^\s\"']+`)
matches := pathPattern.FindAllString(cmd, -1)
for _, raw := range matches {
p, err := filepath.Abs(raw)
if err != nil {
continue