Skip to content

Commit

Permalink
[fud2] Just send Ninja's stdout to our stderr (#2065)
Browse files Browse the repository at this point in the history
This solves a confusing problem where using fud2 in "stdout mode" (i.e.,
without `-o`) would suppress errors from the underlying commands by
default (i.e., unless you *also* remember to use `-v`). We don't want
Ninja printing stuff to stdout, but we also don't like hiding the error
messages, so a sensible solution is to just unconditionally make Ninja's
progress messages go to stderr. Seems reasonable to me, semantically:
all of fud2's output other than the actual content of a "stdout mode"
output should go to stderr.

I also tried "buffering up" the stderr and printing it only when there's
an error. This leads to marginally "cleaner" output in "stdout mode"
because we don't even see Ninja's progress messages. But it also means
buffering and all the various conditions get quite messy... and we also
lose colors in the errors because they don't think they are talking to a
terminal anymore! I think this solution is a bit simpler and better
overall.
  • Loading branch information
sampsyo authored May 27, 2024
1 parent 7398878 commit 10ba39d
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions fud2/fud-core/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,7 @@ impl<'a> Run<'a> {
// Run `ninja` in the working directory.
let mut cmd = Command::new(&self.global_config.ninja);
cmd.current_dir(dir);
if self.plan.stdout && !self.global_config.verbose {
// When we're printing to stdout, suppress Ninja's output by default.
cmd.stdout(std::process::Stdio::null());
}
cmd.stdout(std::io::stderr()); // Send Ninja's stdout to our stderr.
let status = cmd.status()?;

// Emit stdout, only when Ninja succeeded.
Expand Down

0 comments on commit 10ba39d

Please sign in to comment.