mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
os/exec: LookPath on Unix shouldn't look in cwd when PATH is empty
R=golang-dev, dave, bradfitz CC=golang-dev https://golang.org/cl/7305053
This commit is contained in:
parent
80e1cf73eb
commit
fe7dbea00e
2 changed files with 55 additions and 0 deletions
|
|
@ -42,6 +42,9 @@ func LookPath(file string) (string, error) {
|
|||
return "", &Error{file, err}
|
||||
}
|
||||
pathenv := os.Getenv("PATH")
|
||||
if pathenv == "" {
|
||||
return "", &Error{file, ErrNotFound}
|
||||
}
|
||||
for _, dir := range strings.Split(pathenv, ":") {
|
||||
if dir == "" {
|
||||
// Unix shell semantics: path element "" means "."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue