aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/diagnostics.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/diagnostics.cxx')
-rw-r--r--libbuild2/diagnostics.cxx36
1 files changed, 18 insertions, 18 deletions
diff --git a/libbuild2/diagnostics.cxx b/libbuild2/diagnostics.cxx
index 4a46756..c795e44 100644
--- a/libbuild2/diagnostics.cxx
+++ b/libbuild2/diagnostics.cxx
@@ -55,31 +55,31 @@ namespace build2
if (st)
{
- // @@ TMP: eventually we want to enable on Windows by default.
+ // Only attempt to enable if explicitly requested by the user. Note that
+ // while we may enable color for our process, who knows if this gets
+ // inherited by other processes we start (e.g., compilers) and/or
+ // whether they will do something sensible about any of this.
//
-#ifdef _WIN32
- if (c && *c)
+ try
{
-#endif
- stderr_term_color = fdterm_color (stderr_fd (), !c || *c /* enable */);
+ stderr_term_color = fdterm_color (stderr_fd (), c && *c /* enable */);
+ }
+ catch (const io_error& e)
+ {
+ fail << "unable to query terminal color support for stderr: " << e;
+ }
- // If the user specified --diag-color on POSIX we will trust the color
- // is supported (e.g., wrong TERM value, etc).
- //
- if (!stderr_term_color && c && *c)
- {
+ // If the user specified --diag-color on POSIX we will trust the color
+ // is supported (e.g., wrong TERM value, etc).
+ //
+ if (!stderr_term_color && c && *c)
+ {
#ifdef _WIN32
- fail << "unable to enable diagnostics color support for stderr";
+ fail << "unable to enable diagnostics color support for stderr";
#else
- stderr_term_color = true;
+ stderr_term_color = true;
#endif
- }
-
-#ifdef _WIN32
}
- else
- stderr_term_color = false;
-#endif
}
else
stderr_term_color = false;