File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 19
19
// They may not run on Windows, and they do not run in the Go Playground
20
20
// used by golang.org and godoc.org.
21
21
//
22
- // Executables in the current directory
22
+ // # Executables in the current directory
23
23
//
24
24
// The functions Command and LookPath look for a program
25
25
// in the directories listed in the current path, following the
@@ -256,11 +256,16 @@ func Command(name string, arg ...string) *Cmd {
256
256
Args : append ([]string {name }, arg ... ),
257
257
}
258
258
if filepath .Base (name ) == name {
259
- if lp , err := LookPath (name ); err != nil {
260
- cmd .Err = err
261
- } else {
259
+ lp , err := LookPath (name )
260
+ if lp != "" {
261
+ // Update cmd.Path even if err is non-nil.
262
+ // If err is ErrDot (especially on Windows), lp may include a resolved
263
+ // extension (like .exe or .bat) that should be preserved.
262
264
cmd .Path = lp
263
265
}
266
+ if err != nil {
267
+ cmd .Err = err
268
+ }
264
269
}
265
270
return cmd
266
271
}
You can’t perform that action at this time.
0 commit comments