@@ -111,7 +111,7 @@ func (proc *concurrentProcess) wait() {
111111// is resolved in this function.
112112func (proc * concurrentProcess ) newCommandRunner (exe string , combineOutput bool ) (* externalCommand , error ) {
113113 var args []string
114- p , args , err := findExe (exe )
114+ p , args , err := parseExternalCommand (exe )
115115 if err != nil {
116116 return nil , err
117117 }
@@ -124,20 +124,16 @@ func (proc *concurrentProcess) newCommandRunner(exe string, combineOutput bool)
124124 return cmd , nil
125125}
126126
127- func findExe ( exe string ) (string , []string , error ) {
128- p , err := execabs . LookPath ( exe )
129- if err == nil {
130- return p , nil , nil
127+ func parseExternalCommand ( cmd string ) (string , []string , error ) {
128+ a , err := shellwords . Parse ( cmd )
129+ if err != nil || len ( a ) == 0 {
130+ return "" , nil , fmt . Errorf ( "broken command line %q: %w" , cmd , err )
131131 }
132- // See if the command string contains args. As it is best effort, we do not
133- // handle parse errors.
134- if exeArgs , _ := shellwords .Parse (exe ); len (exeArgs ) > 0 {
135- if p , err := execabs .LookPath (exeArgs [0 ]); err == nil {
136- return p , exeArgs [1 :], nil
137- }
132+ c , err := execabs .LookPath (a [0 ])
133+ if err != nil {
134+ return "" , nil , err
138135 }
139-
140- return "" , nil , err
136+ return c , a [1 :], nil
141137}
142138
143139// externalCommand is struct to run specific command concurrently with concurrentProcess bounding
0 commit comments