diff options
Diffstat (limited to 'src/pkg/os/exec/lp_windows.go')
-rw-r--r-- | src/pkg/os/exec/lp_windows.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/pkg/os/exec/lp_windows.go b/src/pkg/os/exec/lp_windows.go index 7c7289bce..c3efd67e9 100644 --- a/src/pkg/os/exec/lp_windows.go +++ b/src/pkg/os/exec/lp_windows.go @@ -24,14 +24,21 @@ func chkStat(file string) error { return nil } +func hasExt(file string) bool { + i := strings.LastIndex(file, ".") + if i < 0 { + return false + } + return strings.LastIndexAny(file, `:\/`) < i +} + func findExecutable(file string, exts []string) (string, error) { if len(exts) == 0 { return file, chkStat(file) } - f := strings.ToLower(file) - for _, e := range exts { - if strings.HasSuffix(f, e) { - return file, chkStat(file) + if hasExt(file) { + if chkStat(file) == nil { + return file, nil } } for _, e := range exts { @@ -47,6 +54,7 @@ func findExecutable(file string, exts []string) (string, error) { // If file contains a slash, it is tried directly and the PATH is not consulted. // LookPath also uses PATHEXT environment variable to match // a suitable candidate. +// The result may be an absolute path or a path relative to the current directory. func LookPath(file string) (f string, err error) { x := os.Getenv(`PATHEXT`) if x == `` { |