From 1488501beda7f2bd0e221667b02a278e1223ff0a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 26 Jul 2024 16:18:48 +0300 Subject: [PATCH] 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 --- src/bin/run_log.rs | 2 -- src/run.rs | 9 +++++---- src/runlog.rs | 6 +----- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/bin/run_log.rs b/src/bin/run_log.rs index e9a6a4a..413ce0b 100644 --- a/src/bin/run_log.rs +++ b/src/bin/run_log.rs @@ -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, ); diff --git a/src/run.rs b/src/run.rs index 8d3269d..609615c 100644 --- a/src/run.rs +++ b/src/run.rs @@ -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, ); diff --git a/src/runlog.rs b/src/runlog.rs index c0d4451..0a21f42 100644 --- a/src/runlog.rs +++ b/src/runlog.rs @@ -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, - stderr: Vec, } 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]) {