@@ -30,6 +30,7 @@ fn check_exit_status(
3030 cwd : Option < & Path > ,
3131 exit_status : ExitStatus ,
3232 output : Option < & Output > ,
33+ show_err : bool ,
3334) -> Result < ( ) , String > {
3435 if exit_status. success ( ) {
3536 return Ok ( ( ) ) ;
@@ -46,7 +47,9 @@ fn check_exit_status(
4647 exit_status. code( )
4748 ) ;
4849 let input = input. iter ( ) . map ( |i| i. as_ref ( ) ) . collect :: < Vec < & OsStr > > ( ) ;
49- eprintln ! ( "Command `{:?}` failed" , input) ;
50+ if show_err {
51+ eprintln ! ( "Command `{:?}` failed" , input) ;
52+ }
5053 if let Some ( output) = output {
5154 let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
5255 if !stdout. is_empty ( ) {
@@ -88,7 +91,7 @@ pub fn run_command_with_env(
8891 let output = get_command_inner ( input, cwd, env)
8992 . output ( )
9093 . map_err ( |e| command_error ( input, & cwd, e) ) ?;
91- check_exit_status ( input, cwd, output. status , Some ( & output) ) ?;
94+ check_exit_status ( input, cwd, output. status , Some ( & output) , true ) ?;
9295 Ok ( output)
9396}
9497
@@ -101,7 +104,7 @@ pub fn run_command_with_output(
101104 . map_err ( |e| command_error ( input, & cwd, e) ) ?
102105 . wait ( )
103106 . map_err ( |e| command_error ( input, & cwd, e) ) ?;
104- check_exit_status ( input, cwd, exit_status, None ) ?;
107+ check_exit_status ( input, cwd, exit_status, None , true ) ?;
105108 Ok ( ( ) )
106109}
107110
@@ -115,7 +118,21 @@ pub fn run_command_with_output_and_env(
115118 . map_err ( |e| command_error ( input, & cwd, e) ) ?
116119 . wait ( )
117120 . map_err ( |e| command_error ( input, & cwd, e) ) ?;
118- check_exit_status ( input, cwd, exit_status, None ) ?;
121+ check_exit_status ( input, cwd, exit_status, None , true ) ?;
122+ Ok ( ( ) )
123+ }
124+
125+ pub fn run_command_with_output_and_env_no_err (
126+ input : & [ & dyn AsRef < OsStr > ] ,
127+ cwd : Option < & Path > ,
128+ env : Option < & HashMap < String , String > > ,
129+ ) -> Result < ( ) , String > {
130+ let exit_status = get_command_inner ( input, cwd, env)
131+ . spawn ( )
132+ . map_err ( |e| command_error ( input, & cwd, e) ) ?
133+ . wait ( )
134+ . map_err ( |e| command_error ( input, & cwd, e) ) ?;
135+ check_exit_status ( input, cwd, exit_status, None , false ) ?;
119136 Ok ( ( ) )
120137}
121138
0 commit comments