Skip to content

Commit fc7d485

Browse files
committed
fix(run): fix hardcoded path separator and deduplicate PATH for tasks
1 parent c8973de commit fc7d485

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

cmd/25.run.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,31 @@ func runTaskCommand(cmd *cobra.Command, args []string) error {
169169

170170
// Prepare environment injects
171171
shimsDir := env.GetShimsDir()
172+
173+
// Safe PATH merging to avoid hardcoded colons and exponential explosion on Windows
174+
newPath := shimsDir + string(os.PathListSeparator) + env.Get("PATH")
175+
176+
// Deduplicate inline to keep PATH clean
177+
parts := strings.Split(newPath, string(os.PathListSeparator))
178+
seen := make(map[string]bool)
179+
var result []string
180+
for _, p := range parts {
181+
if p == "" {
182+
continue
183+
}
184+
key := p
185+
if string(os.PathSeparator) == "\\" { // Windows check
186+
key = strings.ToLower(p)
187+
}
188+
if !seen[key] {
189+
seen[key] = true
190+
result = append(result, p)
191+
}
192+
}
193+
cleanPath := strings.Join(result, string(os.PathListSeparator))
194+
172195
envInjects := []string{
173-
fmt.Sprintf("PATH=%s:%s", shimsDir, env.Get("PATH")),
196+
fmt.Sprintf("PATH=%s", cleanPath),
174197
}
175198

176199
isFix, _ := cmd.Flags().GetBool("fix")

0 commit comments

Comments
 (0)