|
1 |
| -use std::collections::HashMap; |
2 | 1 | use std::env;
|
3 | 2 | use std::ffi::OsString;
|
4 |
| -use std::fmt::Write as _; |
5 | 3 | use std::fs::File;
|
6 | 4 | use std::io::{self, BufWriter, Read, Write};
|
7 | 5 | use std::ops::Not;
|
@@ -247,46 +245,10 @@ pub fn local_crates(metadata: &Metadata) -> String {
|
247 | 245 | local_crates
|
248 | 246 | }
|
249 | 247 |
|
250 |
| -fn env_vars_from_cmd(cmd: &Command) -> Vec<(String, String)> { |
251 |
| - let mut envs = HashMap::new(); |
252 |
| - for (key, value) in std::env::vars() { |
253 |
| - envs.insert(key, value); |
254 |
| - } |
255 |
| - for (key, value) in cmd.get_envs() { |
256 |
| - if let Some(value) = value { |
257 |
| - envs.insert(key.to_string_lossy().to_string(), value.to_string_lossy().to_string()); |
258 |
| - } else { |
259 |
| - envs.remove(&key.to_string_lossy().to_string()); |
260 |
| - } |
261 |
| - } |
262 |
| - let mut envs: Vec<_> = envs.into_iter().collect(); |
263 |
| - envs.sort(); |
264 |
| - envs |
265 |
| -} |
266 |
| - |
267 | 248 | /// Debug-print a command that is going to be run.
|
268 | 249 | pub fn debug_cmd(prefix: &str, verbose: usize, cmd: &Command) {
|
269 | 250 | if verbose == 0 {
|
270 | 251 | return;
|
271 | 252 | }
|
272 |
| - // We only do a single `eprintln!` call to minimize concurrency interactions. |
273 |
| - let mut out = prefix.to_string(); |
274 |
| - writeln!(out, " running command: env \\").unwrap(); |
275 |
| - if verbose > 1 { |
276 |
| - // Print the full environment this will be called in. |
277 |
| - for (key, value) in env_vars_from_cmd(cmd) { |
278 |
| - writeln!(out, "{key}={value:?} \\").unwrap(); |
279 |
| - } |
280 |
| - } else { |
281 |
| - // Print only what has been changed for this `cmd`. |
282 |
| - for (var, val) in cmd.get_envs() { |
283 |
| - if let Some(val) = val { |
284 |
| - writeln!(out, "{}={val:?} \\", var.to_string_lossy()).unwrap(); |
285 |
| - } else { |
286 |
| - writeln!(out, "--unset={}", var.to_string_lossy()).unwrap(); |
287 |
| - } |
288 |
| - } |
289 |
| - } |
290 |
| - write!(out, "{cmd:?}").unwrap(); |
291 |
| - eprintln!("{out}"); |
| 253 | + eprintln!("{prefix} running command: {cmd:?}"); |
292 | 254 | }
|
0 commit comments