@@ -30,6 +30,7 @@ fn check_exit_status(
30
30
cwd : Option < & Path > ,
31
31
exit_status : ExitStatus ,
32
32
output : Option < & Output > ,
33
+ show_err : bool ,
33
34
) -> Result < ( ) , String > {
34
35
if exit_status. success ( ) {
35
36
return Ok ( ( ) ) ;
@@ -46,7 +47,9 @@ fn check_exit_status(
46
47
exit_status. code( )
47
48
) ;
48
49
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
+ }
50
53
if let Some ( output) = output {
51
54
let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
52
55
if !stdout. is_empty ( ) {
@@ -88,7 +91,7 @@ pub fn run_command_with_env(
88
91
let output = get_command_inner ( input, cwd, env)
89
92
. output ( )
90
93
. 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 ) ?;
92
95
Ok ( output)
93
96
}
94
97
@@ -101,7 +104,7 @@ pub fn run_command_with_output(
101
104
. map_err ( |e| command_error ( input, & cwd, e) ) ?
102
105
. wait ( )
103
106
. 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 ) ?;
105
108
Ok ( ( ) )
106
109
}
107
110
@@ -115,7 +118,21 @@ pub fn run_command_with_output_and_env(
115
118
. map_err ( |e| command_error ( input, & cwd, e) ) ?
116
119
. wait ( )
117
120
. 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 ) ?;
119
136
Ok ( ( ) )
120
137
}
121
138
0 commit comments