fix: return correct error in find exec function and stat always

windows-fixes
TorchedSammy 2022-03-16 19:40:51 -04:00
parent c3f3b5c6a4
commit bcce4da92c
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
2 changed files with 7 additions and 7 deletions

View File

@ -172,7 +172,7 @@ func lookpath(file string) error { // custom lookpath function so we know if a c
if err == errNotExec {
return err
} else if err == nil {
return execName, nil
return nil
}
}

View File

@ -3,14 +3,12 @@
package main
import (
"fmt"
"path/filepath"
"os"
)
func findExecutable(path string) error {
nameExt := filepath.Ext(path)
if nameExt == "" {
for _, ext := range filepath.SplitList(os.Getenv("PATHEXT")) {
_, err := os.Stat(path + ext)
@ -18,10 +16,12 @@ func findExecutable(path string) error {
return nil
}
}
} else {
_, err := os.Stat(path)
return err
}
return errNotExec
_, err := os.Stat(path)
if err == nil {
return errNotExec
}
return os.ErrNotExist
}