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 f, err = findExecutable(`.\`+file, exts); err == nil {
return
}
if pathenv := os.Getenv(`PATH`); pathenv != `` {
for _, dir := range strings.Split(pathenv, `;`) {
if f, err = findExecutable(dir+`\`+file, exts); err == nil {
return