@@ -3,7 +3,7 @@ use crate::{process, CmdResult, FunResult};
33use os_pipe:: PipeReader ;
44use std:: any:: Any ;
55use std:: fmt:: Display ;
6- use std:: io:: { BufRead , BufReader , Error , ErrorKind , Read , Result } ;
6+ use std:: io:: { BufRead , BufReader , Error , Read , Result } ;
77use std:: process:: { Child , ExitStatus } ;
88use std:: thread:: JoinHandle ;
99
@@ -37,9 +37,11 @@ impl CmdChildren {
3737 let last_child_res = last_child. wait ( true ) ;
3838 let other_children_res = Self :: wait_children ( & mut self . children ) ;
3939
40- self . ignore_error
41- . then_some ( Ok ( ( ) ) )
42- . unwrap_or ( last_child_res. and ( other_children_res) )
40+ if self . ignore_error {
41+ Ok ( ( ) )
42+ } else {
43+ last_child_res. and ( other_children_res)
44+ }
4345 }
4446
4547 fn wait_children ( children : & mut Vec < CmdChild > ) -> CmdResult {
@@ -166,9 +168,11 @@ impl FunChildren {
166168 let other_children_res = CmdChildren :: wait_children ( & mut self . children ) ;
167169 let _ = stderr_thread. join ( ) ;
168170
169- self . ignore_error
170- . then_some ( Ok ( ( ) ) )
171- . unwrap_or ( last_child_res. and ( other_children_res) )
171+ if self . ignore_error {
172+ Ok ( ( ) )
173+ } else {
174+ last_child_res. and ( other_children_res)
175+ }
172176 }
173177
174178 /// Returns the OS-assigned process identifiers associated with these children processes.
@@ -183,10 +187,11 @@ impl FunChildren {
183187 let last_child = self . children . pop ( ) . unwrap ( ) ;
184188 let last_child_res = last_child. wait_with_all ( capture_stderr, & mut stdout, & mut stderr) ;
185189 let other_children_res = CmdChildren :: wait_children ( & mut self . children ) ;
186- let cmd_result = self
187- . ignore_error
188- . then_some ( Ok ( ( ) ) )
189- . unwrap_or ( last_child_res. and ( other_children_res) ) ;
190+ let cmd_result = if self . ignore_error {
191+ Ok ( ( ) )
192+ } else {
193+ last_child_res. and ( other_children_res)
194+ } ;
190195
191196 let mut stdout: String = String :: from_utf8_lossy ( & stdout) . into ( ) ;
192197 if stdout. ends_with ( '\n' ) {
@@ -345,10 +350,9 @@ trait ChildOutcome: Display {
345350 if self . success ( ) {
346351 Ok ( ( ) )
347352 } else {
348- Err ( Error :: new (
349- ErrorKind :: Other ,
350- format ! ( "Running [{cmd}] exited with error; {self} at {file}:{line}" ) ,
351- ) )
353+ Err ( Error :: other ( format ! (
354+ "Running [{cmd}] exited with error; {self} at {file}:{line}"
355+ ) ) )
352356 }
353357 }
354358}
@@ -392,10 +396,9 @@ impl CmdChildHandle {
392396 format ! ( "Killing process [{cmd}] failed with error: {e} at {file}:{line}" ) ,
393397 )
394398 } ) ,
395- CmdChildHandle :: Thread ( _thread) => Err ( Error :: new (
396- ErrorKind :: Other ,
397- format ! ( "Killing thread [{cmd}] failed: not supported at {file}:{line}" ) ,
398- ) ) ,
399+ CmdChildHandle :: Thread ( _thread) => Err ( Error :: other ( format ! (
400+ "Killing thread [{cmd}] failed: not supported at {file}:{line}"
401+ ) ) ) ,
399402 CmdChildHandle :: SyncFn => Ok ( ( ) ) ,
400403 }
401404 }
0 commit comments