1
0
mirror of https://github.com/golang/go synced 2024-11-20 09:04:44 -07:00

exec.LookPath: return os.PathError instad of os.ENOENT, it's more descriptive.

R=rsc
CC=golang-dev
https://golang.org/cl/3448042
This commit is contained in:
Michael Hoisie 2010-12-07 15:57:00 -05:00 committed by Russ Cox
parent 688a83128d
commit bfac91a6b9
2 changed files with 4 additions and 4 deletions

View File

@ -29,7 +29,7 @@ func LookPath(file string) (string, os.Error) {
if canExec(file) {
return file, nil
}
return "", os.ENOENT
return "", &os.PathError{"lookpath", file, os.ENOENT}
}
pathenv := os.Getenv("PATH")
for _, dir := range strings.Split(pathenv, ":", -1) {
@ -41,5 +41,5 @@ func LookPath(file string) (string, os.Error) {
return dir + "/" + file, nil
}
}
return "", os.ENOENT
return "", &os.PathError{"lookpath", file, os.ENOENT}
}

View File

@ -49,7 +49,7 @@ func LookPath(file string) (string, os.Error) {
if f, ok := canExec(file, exts); ok {
return f, nil
}
return ``, os.ENOENT
return ``, &os.PathError{"lookpath", file, os.ENOENT}
}
if pathenv := os.Getenv(`PATH`); pathenv == `` {
if f, ok := canExec(`.\`+file, exts); ok {
@ -62,5 +62,5 @@ func LookPath(file string) (string, os.Error) {
}
}
}
return ``, os.ENOENT
return ``, &os.PathError{"lookpath", file, os.ENOENT}
}