diff --git a/CHANGELOG.md b/CHANGELOG.md index e979c21..d3d43c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Commander Changelog +### Bug Fixes + +- Better detection of ANSI support in output tty. + [#43](https://github.com/kylef/Commander/issues/43) + ## 0.6.0 ### Enhancements diff --git a/Sources/Error.swift b/Sources/Error.swift index 11345e8..8efea16 100644 --- a/Sources/Error.swift +++ b/Sources/Error.swift @@ -12,7 +12,9 @@ protocol ANSIConvertible : Error, CustomStringConvertible { extension ANSIConvertible { func print() { - if isatty(fileno(stderr)) != 0 { + // Check if we are in any term env and the output is a tty. + if let termType = getenv("TERM"), String(cString: termType).lowercased() != "dumb" && + isatty(fileno(stdout)) != 0 { fputs("\(ansiDescription)\n", stderr) } else { fputs("\(description)\n", stderr)