BetterErrors
BetterErrors copied to clipboard
Make default terminal output cleaner
(Now that cba093bf5d5e328ab581c8d9064fc840ec09eaa8 handles the default cases better this is slightly less relevant, but nonetheless desirable to solve)
Current situation: ocamlc
outputs compiler errors to stderr, while make
+ oasis
outputs error to stdout (and leaves some simple failure message in stderr).
If we want to keep using pipes in conjunction with this repo's script (instead of using the heavy-handed solution of wrapping around ocamlc
a-la ocamlfind
), then for brevity we have no choice but to use |&
(aka pipe both stderr and stdout to stdin) to catch all the errors possibility present at either location.
This is fine, but when we run make
with oasis (which defers to ocamlbuild
), the output looks like this:
But if we intercept it through stdin, and simply pipe out the result out again, we get this:
In our specific case, when we detect no error we output a green check mark along with what we got piped in from stdin. So it's basically this:
(Remember that
|&
receives stderr and stdout, so it's similar to the situation in the 2nd screenshot)
I'm positive make
is overriding terminal output in order not to be noisy. In fact, we see a little progress bar going on while it's making. But for the life of me I don't understand why I can't capture that and pipe it out normally*, instead of seeing a bunch of log output.
More info on how to override terminal output (on OSX it's \r\c
)
Potentially relevant source code
* I've tested a script where it waits for stdin and outputs every char as soon as possible. With this I've captured my self-made progress bar without it being able to erase old characters. But it doesn't work with make
. It just doesn't see the progress bar and the message in the first screenshot at all...?