]> Cypherpunks repositories - gostls13.git/commitdiff
os/exec: make LookPath always search the current directory under Windows.
authorBenny Siegert <bsiegert@gmail.com>
Fri, 2 Dec 2011 03:29:24 +0000 (14:29 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Fri, 2 Dec 2011 03:29:24 +0000 (14:29 +1100)
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

src/pkg/os/exec/lp_windows.go

index ef5bd921668f7e613242a0f2c5a4082099b6d3ad..d09e839a397693502c2e492bf5fbcb6713a5eb9d 100644 (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