put code in right palce
This commit is contained in:
parent
991429a290
commit
182f75e37a
1 changed files with 9 additions and 10 deletions
19
linux/run.go
19
linux/run.go
|
@ -51,6 +51,15 @@ func (cmd *LinuxCommand) AddHandler(handler interface{}) error {
|
||||||
|
|
||||||
func (cmd *LinuxCommand) Run() 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
|
var sourceCommand strings.Builder
|
||||||
for _, value := range cmd.Options.Sources {
|
for _, value := range cmd.Options.Sources {
|
||||||
sourceCommand.WriteString(fmt.Sprintf("source %s && ", value))
|
sourceCommand.WriteString(fmt.Sprintf("source %s && ", value))
|
||||||
|
@ -100,7 +109,6 @@ func (cmd *LinuxCommand) Run() error {
|
||||||
if err := command.Start(); err != nil {
|
if err := command.Start(); err != nil {
|
||||||
var exitErr *exec.ExitError
|
var exitErr *exec.ExitError
|
||||||
if errors.As(err, &exitErr) {
|
if errors.As(err, &exitErr) {
|
||||||
fmt.Println(exitErr.String())
|
|
||||||
if exitErr.ExitCode() == 127 {
|
if exitErr.ExitCode() == 127 {
|
||||||
return ErrCommandNotFound
|
return ErrCommandNotFound
|
||||||
} else if _, ok := cmd.Options.CustomErrors[int8(exitErr.ExitCode())]; ok {
|
} 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
|
var exitInfo *EventExitData
|
||||||
|
|
||||||
if _, ok := cmd.handlers[EventExit]; ok {
|
if _, ok := cmd.handlers[EventExit]; ok {
|
||||||
|
|
Loading…
Reference in a new issue