@@ -202,7 +202,7 @@ impl ProcessBuilder {
202
202
& self ,
203
203
on_stdout_line : & mut FnMut ( & str ) -> CargoResult < ( ) > ,
204
204
on_stderr_line : & mut FnMut ( & str ) -> CargoResult < ( ) > ,
205
- print_output : bool ,
205
+ capture_output : bool ,
206
206
) -> CargoResult < Output > {
207
207
let mut stdout = Vec :: new ( ) ;
208
208
let mut stderr = Vec :: new ( ) ;
@@ -226,23 +226,33 @@ impl ProcessBuilder {
226
226
None => return ,
227
227
}
228
228
} ;
229
- let data = data. drain ( ..idx) ;
230
- let dst = if is_out { & mut stdout } else { & mut stderr } ;
231
- let start = dst. len ( ) ;
232
- dst. extend ( data) ;
233
- for line in String :: from_utf8_lossy ( & dst[ start..] ) . lines ( ) {
234
- if callback_error. is_some ( ) {
235
- break ;
236
- }
237
- let callback_result = if is_out {
238
- on_stdout_line ( line)
229
+ { // scope for new_lines
230
+ let new_lines = if capture_output {
231
+ let dst = if is_out { & mut stdout } else { & mut stderr } ;
232
+ let start = dst. len ( ) ;
233
+ let data = data. drain ( ..idx) ;
234
+ dst. extend ( data) ;
235
+ & dst[ start..]
239
236
} else {
240
- on_stderr_line ( line )
237
+ & data [ ..idx ]
241
238
} ;
242
- if let Err ( e) = callback_result {
243
- callback_error = Some ( e) ;
239
+ for line in String :: from_utf8_lossy ( new_lines) . lines ( ) {
240
+ if callback_error. is_some ( ) {
241
+ break ;
242
+ }
243
+ let callback_result = if is_out {
244
+ on_stdout_line ( line)
245
+ } else {
246
+ on_stderr_line ( line)
247
+ } ;
248
+ if let Err ( e) = callback_result {
249
+ callback_error = Some ( e) ;
250
+ }
244
251
}
245
252
}
253
+ if !capture_output {
254
+ data. drain ( ..idx) ;
255
+ }
246
256
} ) ?;
247
257
child. wait ( )
248
258
} ) ( )
@@ -260,7 +270,7 @@ impl ProcessBuilder {
260
270
} ;
261
271
262
272
{
263
- let to_print = if print_output { Some ( & output) } else { None } ;
273
+ let to_print = if capture_output { Some ( & output) } else { None } ;
264
274
if !output. status . success ( ) {
265
275
return Err ( process_error (
266
276
& format ! ( "process didn't exit successfully: {}" , self ) ,
0 commit comments