Skip to content

Commit

Permalink
feat: Better ANSI support detection. (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe authored and kylef committed Dec 15, 2016
1 parent 2779764 commit e45aa71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion Sources/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e45aa71

Please sign in to comment.