From 182f75e37a6f361ad28457f2a576f87f85e112f3 Mon Sep 17 00:00:00 2001 From: Shane C Date: Tue, 9 Jul 2024 19:13:10 -0400 Subject: [PATCH] put code in right palce --- linux/run.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/linux/run.go b/linux/run.go index f83aa10..960fd37 100644 --- a/linux/run.go +++ b/linux/run.go @@ -51,6 +51,15 @@ func (cmd *LinuxCommand) AddHandler(handler interface{}) error { func (cmd *LinuxCommand) Run() error { + isCommandExecutable, err := cmd.isCommandExecutable(cmd.Options.Command) + if err != nil { + return err + } + + if !isCommandExecutable { + return ErrCommandNotExecutable + } + var sourceCommand strings.Builder for _, value := range cmd.Options.Sources { sourceCommand.WriteString(fmt.Sprintf("source %s && ", value)) @@ -100,7 +109,6 @@ func (cmd *LinuxCommand) Run() error { if err := command.Start(); err != nil { var exitErr *exec.ExitError if errors.As(err, &exitErr) { - fmt.Println(exitErr.String()) if exitErr.ExitCode() == 127 { return ErrCommandNotFound } else if _, ok := cmd.Options.CustomErrors[int8(exitErr.ExitCode())]; ok { @@ -160,15 +168,6 @@ func (cmd *LinuxCommand) Run() error { } }() - isCommandExecutable, err := cmd.isCommandExecutable(cmd.Options.Command) - if err != nil { - return err - } - - if !isCommandExecutable { - return ErrCommandNotExecutable - } - var exitInfo *EventExitData if _, ok := cmd.handlers[EventExit]; ok {