mirror of
https://seed.radicle.dev/rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE.git
synced 2026-11-29 14:30:32 +08:00
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:
@@ -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
@@ -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
@@ -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]) {
|
||||
|
||||
Reference in New Issue
Block a user