diff --git a/icmd/command.go b/icmd/command.go index a15834b..e74d01c 100644 --- a/icmd/command.go +++ b/icmd/command.go @@ -207,10 +207,7 @@ func Command(command string, args ...string) Cmd { // RunCmd runs a command and returns a Result func RunCmd(cmd Cmd, cmdOperators ...CmdOp) *Result { - for _, op := range cmdOperators { - op(&cmd) - } - result := StartCmd(cmd) + result := StartCmd(cmd, cmdOperators...) if result.Error != nil { return result } @@ -223,7 +220,10 @@ func RunCommand(command string, args ...string) *Result { } // StartCmd starts a command, but doesn't wait for it to finish -func StartCmd(cmd Cmd) *Result { +func StartCmd(cmd Cmd, cmdOperators ...CmdOp) *Result { + for _, op := range cmdOperators { + op(&cmd) + } result := buildCmd(cmd) if result.Error != nil { return result