Skip to content

Commit

Permalink
Utility: make Debug::isTty() more reliable on macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
mosra committed Jul 22, 2019
1 parent 0e21f1a commit a3fb70a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 9 additions & 0 deletions doc/corrade-changelog.dox
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ namespace Corrade {
if one of them failed to open (see [mosra/corrade#70](https://github.com/mosra/corrade/pull/70))
- @ref Interconnect::Emitter::emit() (and signal/slot connections in general)
now work correctly with non-copyable arguments
- Fixed @ref Utility::Debug::isTty() (and thus also @ref TestSuite colored
output) to reliably work on macOS. Because Xcode output window doesn't
support ANSI color escape codes, tt was relying on an undocumented
@cb{.sh} $XPC_SERVICE_NAME @ce variable that was always defined inside
Xcode to disable colored output. Nowadays this variable is sometimes
defined outside as well, making the check unreliable. Fixed by testing for
@cb{.sh} $TERM @ce instead, see
[mosra/corrade#73](https://github.com/mosra/corrade/issues/73) for more
information.

@subsection corrade-changelog-latest-deprecated Deprecated APIs

Expand Down
9 changes: 6 additions & 3 deletions src/Corrade/Utility/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,12 @@ bool Debug::isTty(std::ostream* const output) {
#endif
#ifdef CORRADE_TARGET_APPLE
/* Xcode's console reports that it is a TTY, but it doesn't support
colors. We have to check for the following undocumented environment
variable instead. If set, then don't use colors. */
&& !std::getenv("XPC_SERVICE_NAME")
colors. Originally this was testing for XPC_SERVICE_NAME being
defined because that's always defined when running inside Xcode, but
nowadays that's often defined also outside of Xcode, so it's
useless. According to https://stackoverflow.com/a/39292112, we can
reliably check for TERM -- if it's null, we're inside Xcode. */
&& std::getenv("TERM")
#endif
;

Expand Down

0 comments on commit a3fb70a

Please sign in to comment.