feat: combine stdout and stderr into one stream

This makes it easier, for me, to follow the output. It's more like
what I see in the terminal if I run the commands directly. If this
turns out to be bad for others, I'll revert.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2024-07-26 16:18:48 +03:00
parent d4141ef671
commit 1488501bed
3 changed files with 6 additions and 11 deletions
-2
View File
@@ -28,7 +28,6 @@ fn main() {
Path::new("/tmp"),
0,
"This is stdout".as_bytes(),
"Error messages go here".as_bytes(),
started,
ended,
);
@@ -37,7 +36,6 @@ fn main() {
Path::new("/tmp"),
0,
"This is stdout".as_bytes(),
"Error messages go here".as_bytes(),
started,
ended,
);
+5 -4
View File
@@ -207,9 +207,11 @@ impl Run {
}
let started = SystemTime::now();
let argv0 = argv[0];
let output = Command::new(argv0)
.args(&argv[1..])
let output = Command::new("bash")
.arg("-c")
.arg(r#""$@" 2>&1"#)
.arg("--")
.args(argv)
.current_dir(cwd)
.output()
.map_err(|e| RunError::Command(argv.iter().map(|s| s.to_string()).collect(), e))?;
@@ -222,7 +224,6 @@ impl Run {
.map_err(|e| RunError::Canonicalize(cwd.into(), e))?,
exit,
&output.stdout,
&output.stderr,
started,
ended,
);
+1 -5
View File
@@ -82,7 +82,6 @@ impl RunLog {
cwd: &Path,
exit: i32,
stdout: &[u8],
stderr: &[u8],
started: SystemTime,
ended: SystemTime,
) {
@@ -94,7 +93,6 @@ impl RunLog {
cwd: cwd.into(),
exit,
stdout: stdout.to_vec(),
stderr: stderr.to_vec(),
});
}
@@ -217,7 +215,6 @@ struct Command {
cwd: PathBuf,
exit: i32,
stdout: Vec<u8>,
stderr: Vec<u8>,
}
impl Command {
@@ -267,8 +264,7 @@ impl Command {
body.push_child(Element::new(Tag::P).with_text(&format!("Exit code: {}", self.exit)));
self.output(body, "Stdout:", &self.stdout);
self.output(body, "Stderr:", &self.stderr);
self.output(body, "Output (stdout and stderr):", &self.stdout);
}
fn output(&self, body: &mut Element, stream: &str, data: &[u8]) {