Skip to content

Commit ccc019a

Browse files
committed
process Debug WIP (rust-lang#42200)
1 parent c9bb935 commit ccc019a

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/libstd/process.rs

-3
Original file line numberDiff line numberDiff line change
@@ -671,9 +671,6 @@ impl Command {
671671

672672
#[stable(feature = "rust1", since = "1.0.0")]
673673
impl fmt::Debug for Command {
674-
/// Format the program and arguments of a Command for display. Any
675-
/// non-utf8 data is lossily converted using the utf8 replacement
676-
/// character.
677674
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
678675
self.inner.fmt(f)
679676
}

src/libstd/sys/unix/process/process_common.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub enum ChildStdio {
8181
Owned(FileDesc),
8282
}
8383

84+
#[derive(Debug)]
8485
pub enum Stdio {
8586
Inherit,
8687
Null,
@@ -351,11 +352,20 @@ fn pair_to_key(key: &OsStr, value: &OsStr, saw_nul: &mut bool) -> CString {
351352

352353
impl fmt::Debug for Command {
353354
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
354-
write!(f, "{:?}", self.program)?;
355-
for arg in &self.args {
356-
write!(f, " {:?}", arg)?;
357-
}
358-
Ok(())
355+
f.debug_struct("Command")
356+
.field("program", &self.program)
357+
.field("args", &self.args)
358+
.field("env", &self.env)
359+
.field("argv", &self.argv)
360+
.field("envp", &self.envp)
361+
.field("cwd", &self.cwd)
362+
.field("uid", &self.uid)
363+
.field("gid", &self.gid)
364+
.field("saw_nul", &self.saw_nul)
365+
.field("stdin", &self.stdin)
366+
.field("stdout", &self.stdout)
367+
.field("stderr", &self.stderr)
368+
.finish()
359369
}
360370
}
361371

0 commit comments

Comments
 (0)