diff options
author | Hannes Mehnert <hannes@mehnert.org> | 2017-03-11 11:38:59 +0000 |
---|---|---|
committer | Hannes Mehnert <hannes@mehnert.org> | 2017-03-15 08:24:13 +0000 |
commit | 76bf7c568e7997efd1a80073782f0eddfb2cecaa (patch) | |
tree | 3a4f3ac69410d13c4ff7cdcb08a095e950dafdbe /man | |
parent | 3ed575adbf22f8650ec625fb5c5cb5b235f89cd6 (diff) | |
download | ocaml-76bf7c568e7997efd1a80073782f0eddfb2cecaa.tar.gz |
Respect OCAML_COLOR environment variable for deciding whether to use colors
Since 4.03, OCaml supports coloring its messages to standard output and standard
error, depending on the "-color" argument ({always,never,auto}). This commit
adds support for the environment variable "OCAML_COLOR" (which value can as well
be {always,never,auto}).
The command line argument "-color" takes precedence, "OCAML_COLOR" is only
taken into consideration if no "-color" is provided.
The motivation for this is that the user should have control over coloring
OCaml's output messages. OCamlbuild, a widely used build tool executes OCaml
not under a tty (and OCaml does not colorize errors and warnings), which lead
various packages use `color(always)` in their `_tags` files, which breaks with
other (non-interactive) programs (i.e. editor helpers).
Further discussion was done at https://github.com/ocaml/ocamlbuild/issues/87 and
https://github.com/ocaml/ocaml/pull/1098.
Diffstat (limited to 'man')
-rw-r--r-- | man/ocamlc.m | 3 | ||||
-rw-r--r-- | man/ocamlopt.m | 24 |
2 files changed, 27 insertions, 0 deletions
diff --git a/man/ocamlc.m b/man/ocamlc.m index bf66f6fe74..596b225c8e 100644 --- a/man/ocamlc.m +++ b/man/ocamlc.m @@ -282,6 +282,9 @@ and the current heuristic checks that the "TERM" environment variable exists and is not empty or "dumb", and that isatty(stderr) holds. +The environment variable "OCAML_COLOR" is considered if \-color is not +provided. Its values are auto/always/never as above. + .TP .B \-compat\-32 Check that the generated bytecode executable can run on 32-bit diff --git a/man/ocamlopt.m b/man/ocamlopt.m index 12c96355ec..c5278d46f6 100644 --- a/man/ocamlopt.m +++ b/man/ocamlopt.m @@ -218,6 +218,30 @@ causes the C linker to search for C libraries in directory .IR dir . .TP +.BI \-color \ mode +Enable or disable colors in compiler messages (especially warnings and errors). +The following modes are supported: + +.B auto +use heuristics to enable colors only if the output supports them (an +ANSI-compatible tty terminal); + +.B always +enable colors unconditionally; + +.B never +disable color output. + +The default setting is +.B auto, +and the current heuristic +checks that the "TERM" environment variable exists and is +not empty or "dumb", and that isatty(stderr) holds. + +The environment variable "OCAML_COLOR" is considered if \-color is not +provided. Its values are auto/always/never as above. + +.TP .B \-compact Optimize the produced code for space rather than for time. This results in smaller but slightly slower programs. The default is to |