@@ -159,14 +159,13 @@ func absEnv(envNameList []string, argList []string) error {
159
159
}
160
160
161
161
func runAndLogCommand (cmd * exec.Cmd , verbose bool ) error {
162
- formattedCmd := formatCommand (cmd )
163
162
if verbose {
164
- os .Stderr . WriteString ( formattedCmd )
163
+ fmt . Fprintln ( os .Stderr , formatCommand ( cmd ) )
165
164
}
166
165
cleanup := passLongArgsInResponseFiles (cmd )
167
166
defer cleanup ()
168
167
if err := cmd .Run (); err != nil {
169
- return fmt .Errorf ("error running the following subcommand: %v\n %s " , err , formattedCmd )
168
+ return fmt .Errorf ("error running subcommand %s : %v" , cmd . Path , err )
170
169
}
171
170
return nil
172
171
}
@@ -333,8 +332,8 @@ func absArgs(args []string, flags []string) {
333
332
}
334
333
}
335
334
336
- // formatCommand writes cmd to w in a format where it can be pasted into a
337
- // shell. Spaces in environment variables and arguments are escaped as needed.
335
+ // formatCommand formats cmd as a string that can be pasted into a shell.
336
+ // Spaces in environment variables and arguments are escaped as needed.
338
337
func formatCommand (cmd * exec.Cmd ) string {
339
338
quoteIfNeeded := func (s string ) string {
340
339
if strings .IndexByte (s , ' ' ) < 0 {
@@ -367,7 +366,6 @@ func formatCommand(cmd *exec.Cmd) string {
367
366
fmt .Fprintf (& w , "%s%s" , sep , quoteIfNeeded (arg ))
368
367
sep = " "
369
368
}
370
- fmt .Fprint (& w , "\n " )
371
369
return w .String ()
372
370
}
373
371
0 commit comments