diff options
| author | kraktus <kraktus@users.noreply.github.com> | 2022-05-19 15:50:27 +0200 |
|---|---|---|
| committer | kraktus <kraktus@users.noreply.github.com> | 2022-12-27 09:50:01 +0100 |
| commit | eb63dea57f4e7d9f07810515b0e43966fc4d78e4 (patch) | |
| tree | 9f8b72b44d47cd64c0fcce6124835b5e9ce0a534 /library/std/src/sys_common/process.rs | |
| parent | 35a99eef32a2b7b9d8e77dde539f869e522d181f (diff) | |
| download | rust-eb63dea57f4e7d9f07810515b0e43966fc4d78e4.tar.gz rust-eb63dea57f4e7d9f07810515b0e43966fc4d78e4.zip | |
More verbose `Debug` implementation of `std::process:Command`
based on commit: https://github.com/zackmdavis/rust/commit/ccc019aabfdd550944c049625e66c92c815ea1d0 from https://github.com/zackmdavis close https://github.com/rust-lang/rust/issues/42200 Add env variables and cwd to the shell-like debug output. Also use the alternate syntax to display a more verbose display, while not showing internal fields and hiding fields when they have their default value.
Diffstat (limited to 'library/std/src/sys_common/process.rs')
| -rw-r--r-- | library/std/src/sys_common/process.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/library/std/src/sys_common/process.rs b/library/std/src/sys_common/process.rs index ae11412067b..18883048dae 100644 --- a/library/std/src/sys_common/process.rs +++ b/library/std/src/sys_common/process.rs @@ -4,12 +4,13 @@ use crate::collections::BTreeMap; use crate::env; use crate::ffi::{OsStr, OsString}; +use crate::fmt; use crate::io; use crate::sys::pipe::read2; use crate::sys::process::{EnvKey, ExitStatus, Process, StdioPipes}; // Stores a set of changes to an environment -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct CommandEnv { clear: bool, saw_path: bool, @@ -22,6 +23,14 @@ impl Default for CommandEnv { } } +impl fmt::Debug for CommandEnv { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut debug_command_env = f.debug_struct("CommandEnv"); + debug_command_env.field("clear", &self.clear).field("vars", &self.vars); + debug_command_env.finish() + } +} + impl CommandEnv { // Capture the current environment with these changes applied pub fn capture(&self) -> BTreeMap<EnvKey, OsString> { |
