diff options
author | Bruno Haible <bruno@clisp.org> | 2019-08-14 02:46:36 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2019-08-14 02:46:36 +0200 |
commit | 7040b13946b3dce5fbe2be8ecfda11e03eed7028 (patch) | |
tree | 4fd8781f35b44732b3913ed5f4187ecc9bc3e9d7 /libtextstyle/doc | |
parent | 8e280e2efdcb9fa9a5e93edb89354496a55f228a (diff) | |
download | gettext-7040b13946b3dce5fbe2be8ecfda11e03eed7028.tar.gz |
libtextstyle: Support the NO_COLOR environment variable.
It follows the specification at https://no-color.org/.
The support is in the example programs, not in the function
styled_ostream_create, so that it can be overridden through the command-line
option --color=always.
We only test whether the environment variable is set, not whether its value
is non-empty. POSIX-specified environment variables are treated like unset
when their value is empty; this is because in the old days it was not possible
to unset an environment variable. But nowadays:
- all shells support the 'unset' built-in,
- all platforms that have the setenv() function also have the unsetenv()
function, and
- the 'env' program from GNU coreutils supports --unset=VARIABLE to unset a
variable.
This makes it possible to unset an environment variable that is set by the
parent process.
* libtextstyle/adhoc-tests/hello.c (main): Do not emit styling when the
environment variable NO_COLOR is set.
* libtextstyle/examples/color-filter/filter.c (main): Likewise.
* libtextstyle/examples/color-hello/hello.c (main): Likewise.
* gettext-tools/src/write-catalog.c (msgdomain_list_print): Likewise.
* libtextstyle/doc/libtextstyle.texi (The NO_COLOR variable): New section.
* libtextstyle/NEWS: Mention it.
Diffstat (limited to 'libtextstyle/doc')
-rw-r--r-- | libtextstyle/doc/libtextstyle.texi | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libtextstyle/doc/libtextstyle.texi b/libtextstyle/doc/libtextstyle.texi index d641a0737..30b955a99 100644 --- a/libtextstyle/doc/libtextstyle.texi +++ b/libtextstyle/doc/libtextstyle.texi @@ -243,6 +243,7 @@ scroll around in the styled output. For example: @menu * The TERM variable:: +* The NO_COLOR variable:: * Emacs:: * The --color option:: * The --style option:: @@ -357,6 +358,19 @@ default @code{TERM=vt100}. On Windows consoles, no @code{TERM} setting is needed. +@node The NO_COLOR variable +@section The environment variable @code{NO_COLOR} + +@vindex NO_COLOR@r{, environment variable} +@c The name of this environment variable is specified by https://no-color.org/. +The environment variable @code{NO_COLOR} can be used to suppress styling +in the textual output. When this environment variable is set (to any value), +@code{libtextstyle}-enabled programs will not emit colors and other text +styling. + +This environment variable can be overridden by passing the command-line option +@samp{--color=always} (see @ref{The --color option}). + @node Emacs @section Emacs as a terminal emulator |