summaryrefslogtreecommitdiff
path: root/src/pkg/exec/lp_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/exec/lp_windows.go')
-rw-r--r--src/pkg/exec/lp_windows.go25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/pkg/exec/lp_windows.go b/src/pkg/exec/lp_windows.go
index 758861021..7581088eb 100644
--- a/src/pkg/exec/lp_windows.go
+++ b/src/pkg/exec/lp_windows.go
@@ -10,7 +10,7 @@ import (
)
// ErrNotFound is the error resulting if a path search failed to find an executable file.
-var ErrNotFound = os.ErrorString("executable file not found in %PATH%")
+var ErrNotFound = os.NewError("executable file not found in %PATH%")
func chkStat(file string) os.Error {
d, err := os.Stat(file)
@@ -38,20 +38,25 @@ func findExecutable(file string, exts []string) (string, os.Error) {
return f, nil
}
}
- return ``, ErrNotFound
+ return ``, os.ENOENT
}
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), `;`) {
+ if e == "" {
+ continue
+ }
+ if e[0] != '.' {
+ e = "." + e
}
+ exts = append(exts, e)
}
- if strings.Contains(file, `\`) || strings.Contains(file, `/`) {
+ if strings.IndexAny(file, `:\/`) != -1 {
if f, err = findExecutable(file, exts); err == nil {
return
}
@@ -62,7 +67,7 @@ func LookPath(file string) (f string, err os.Error) {
return
}
} else {
- for _, dir := range strings.Split(pathenv, `;`, -1) {
+ for _, dir := range strings.Split(pathenv, `;`) {
if f, err = findExecutable(dir+`\`+file, exts); err == nil {
return
}