From bcce4da92cad68ed90f02fb4bcf9be99f4c950bd Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Wed, 16 Mar 2022 19:40:51 -0400 Subject: [PATCH] fix: return correct error in find exec function and stat always --- exec.go | 2 +- execfile_windows.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/exec.go b/exec.go index 0d9e3d4..aae0b4d 100644 --- a/exec.go +++ b/exec.go @@ -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 } } diff --git a/execfile_windows.go b/execfile_windows.go index 6689ecb..a11ea86 100644 --- a/execfile_windows.go +++ b/execfile_windows.go @@ -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 }