Crystal: export TERM=dumb

Created on 3 Oct 2019  路  6Comments  路  Source: crystal-lang/crystal

When setting TERM=dumb I should not get funny stuff.

hello-world -> export TERM=dumb
hello-world -> crystal spec
.

Finished in 119 microseconds
1 examples, 0 failures, 0 errors, 0 pending
hello-world -> 

But I do...

newcomer feature compiler topicspecs

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.cr and compiler/command.cr, and colorize.cr could honour this setting as well.

All 6 comments

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.

  1. I am happy to try work out how to contribute and send a pull request for such a change. In fact I want to! : This would mean working out how to get llvm to build crystal correctly on my Mac. I tried yesterday and got strange errors when doing make spec.. Otherwise I would have sent a pull request already.
  2. I have never used Ruby so cannot comment on whether it honours TERM in the terminal.
  3. I am using the 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.html
  4. I have just started using it together with acme-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.
  5. I can use --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.
  6. Here are some sample links where TERM=dumb is mentioned in which programs are meant to honour the environment variable.

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

Was this page helpful?
0 / 5 - 0 ratings