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 {