@@ -4,8 +4,10 @@ -- ? simple command line driver for the cortav library local ct = require 'cortav' local ss = require 'sirsem' +local native = _G.native + local default_mode = { ['render:format'] = 'html'; ['html:gen-styles'] = true; ['groff:color'] = true; @@ -226,16 +228,22 @@ if ss.exn.is(e) then str = e.kind.desc end local color = false - if log:seek() == nil then - -- this is not a very reliable heuristic for detecting - -- attachment to a tty but it's better than nothing - if os.getenv('COLORTERM') then + if native then + if native.posix.isatty(log) then color = true - else - local term = os.getenv('TERM') - if term:find 'color' then color = true end + end + else + if log:seek() == nil then + -- this is not a very reliable heuristic for detecting + -- attachment to a tty but it's better than nothing + if os.getenv('COLORTERM') then + color = true + else + local term = os.getenv('TERM') + if term:find 'color' then color = true end + end end end if color then str = string.format('\27[1;31m%s\27[m', str)