1
0
mirror of https://github.com/golang/go synced 2024-11-24 22:57:57 -07:00

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
This commit is contained in:
Benny Siegert 2011-12-02 14:29:24 +11:00 committed by Alex Brainman
parent 517503dab8
commit 2a876beb18

View File

@ -63,11 +63,10 @@ func LookPath(file string) (f string, err error) {
}
return ``, &Error{file, err}
}
if pathenv := os.Getenv(`PATH`); pathenv == `` {
if f, err = findExecutable(`.\`+file, exts); err == nil {
return
}
} else {
if pathenv := os.Getenv(`PATH`); pathenv != `` {
for _, dir := range strings.Split(pathenv, `;`) {
if f, err = findExecutable(dir+`\`+file, exts); err == nil {
return