When setting TERM=dumb I should not get funny stuff.
hello-world -> export TERM=dumb
hello-world -> crystal spec
[32m.[0m
Finished in 119 microseconds
[32m1 examples, 0 failures, 0 errors, 0 pending[0m
hello-world ->
But I do...
Sounds like a good idea to disable color output by default when ENV["TERM"] == "dumb".
This should be implemented in both spec.cr and compiler/command.cr, and colorize.cr could honour this setting as well.
Out of curiosity: if you do TERM=dumb rspec with a Ruby project, what happens?
(I tried it on iTerm2 and Terminal on Mac and nothing changes)
Is TERM=dumb something that all programs must take into account? Also, why are you using TERM=dumb? Finally, you can pass --no-color to remove color.
make spec.. Otherwise I would have sent a pull request already. acme editor which does not work with colors, and I set TERM in general to solve this problem. See http://acme.cat-v.org/ , https://ilanpillemer.github.io/subjects/acme.htmlacme-lsp (I need to update my page above with how I use it) but I have not yet tried to integrate with a Crystal lsp server. https://github.com/fhs/acme-lsp. In fact I want to try and get that working over the next week.--no-color buts its clunky and means I have to treat Crystal as a special snowflake. This is what I am doing now, after I figured out you could.TERM=dumb is mentioned in which programs are meant to honour the environment variable. This stack overflow page mentioned Ruby colorizer and says it honours TERM=dumb https://stackoverflow.com/questions/1489183/colorized-ruby-output (scroll down to find it)
I guess we could read Term ENV var when booting "colorize" and always disable it if it's dumb. Spec needs a special treatment too because it uses "\r", which I guess dumb doesn't support?
dumb|80-column dumb tty,
am,
cols#80,
bel=^G, cr=\r, cud1=\n, ind=\n,
From https://invisible-island.net/ncurses/terminfo.src.html#tic-dumb.
So looks like \r is fine.
This can prob be closed, was handled in https://github.com/crystal-lang/crystal/pull/8271
Most helpful comment
Sounds like a good idea to disable color output by default when
ENV["TERM"] == "dumb".This should be implemented in both
spec.crandcompiler/command.cr, andcolorize.crcould honour this setting as well.