Skip to content

Commit 2a876be

Browse files
bsiegertalexbrainman
authored andcommitted
os/exec: make LookPath always search the current directory under Windows.
cmd.exe implicitly looks in "." before consulting PATH. LookPath should match this behavior. R=alex.brainman, rsc CC=golang-dev https://golang.org/cl/5434093
1 parent 517503d commit 2a876be

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/pkg/os/exec/lp_windows.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ func LookPath(file string) (f string, err error) {
6363
}
6464
return ``, &Error{file, err}
6565
}
66-
if pathenv := os.Getenv(`PATH`); pathenv == `` {
67-
if f, err = findExecutable(`.\`+file, exts); err == nil {
68-
return
69-
}
70-
} else {
66+
if f, err = findExecutable(`.\`+file, exts); err == nil {
67+
return
68+
}
69+
if pathenv := os.Getenv(`PATH`); pathenv != `` {
7170
for _, dir := range strings.Split(pathenv, `;`) {
7271
if f, err = findExecutable(dir+`\`+file, exts); err == nil {
7372
return

0 commit comments

Comments
 (0)