diff --git a/man/systemd.xml b/man/systemd.xml
index 65f55199e2..e30333e209 100644
--- a/man/systemd.xml
+++ b/man/systemd.xml
@@ -837,8 +837,10 @@
$SYSTEMD_COLORS
- Controls whether colorized output should be generated.
-
+ The value must be a boolean. Controls whether colorized output should be
+ generated. This can be specified to override the decision that systemd
+ makes based on $TERM and what the console is connected to.
+
@@ -849,7 +851,7 @@
Set by systemd for supervised processes during
socket-based activation. See
sd_listen_fds3
- for more information.
+ for more information.
@@ -858,7 +860,7 @@
Set by systemd for supervised processes for
status and start-up completion notification. See
sd_notify3
- for more information.
+ for more information.
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 19d289275e..bfa936bd4e 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -39,6 +39,7 @@
#include
#include "alloc-util.h"
+#include "env-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
@@ -1212,11 +1213,11 @@ bool colors_enabled(void) {
static int enabled = -1;
if (_unlikely_(enabled < 0)) {
- const char *colors;
+ int val;
- colors = getenv("SYSTEMD_COLORS");
- if (colors)
- enabled = parse_boolean(colors) != 0;
+ val = getenv_bool("SYSTEMD_COLORS");
+ if (val >= 0)
+ enabled = val;
else if (getpid() == 1)
/* PID1 outputs to the console without holding it open all the time */
enabled = !getenv_terminal_is_dumb();