Commit c195cc8d authored by Alex Brainman's avatar Alex Brainman Committed by Russ Cox

exec: make LookPath work even when PATHEXT env variable is not set on Windows

R=golang-dev, mattn.jp
CC=golang-dev
https://golang.org/cl/4559062
parent 5af8e53a
......@@ -42,14 +42,19 @@ func findExecutable(file string, exts []string) (string, os.Error) {
}
func LookPath(file string) (f string, err os.Error) {
x := os.Getenv(`PATHEXT`)
if x == `` {
x = `.COM;.EXE;.BAT;.CMD`
}
exts := []string{}
if x := os.Getenv(`PATHEXT`); x != `` {
exts = strings.Split(strings.ToLower(x), `;`, -1)
for i, e := range exts {
if e == `` || e[0] != '.' {
exts[i] = `.` + e
}
for _, e := range strings.Split(strings.ToLower(x), `;`, -1) {
if e == "" {
continue
}
if e[0] != '.' {
e = "." + e
}
exts = append(exts, e)
}
if strings.Contains(file, `\`) || strings.Contains(file, `/`) {
if f, err = findExecutable(file, exts); err == nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment