summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-08-19 10:26:27 -0400
committerSven Eden <yamakuzure@gmx.net>2017-07-05 08:50:52 +0200
commite28a8a014111dbbd4083c0c5790d484001388fbe (patch)
tree01d89ffedc0b1775134d8c72e4e9e9a5a1d273ba
parent3a836f9f8143f2f69951d6ca6d47f9937cf43419 (diff)
terminal-util: use getenv_bool for $SYSTEMD_COLORS
This changes the semantics a bit: before, SYSTEMD_COLORS= would be treated as "yes", same as SYSTEMD_COLORS=xxx and SYSTEMD_COLORS=1, and only SYSTEMD_COLORS=0 would be treated as "no". Now, only valid booleans are treated as "yes". This actually matches how $SYSTEMD_COLORS was announced in NEWS.
-rw-r--r--src/basic/terminal-util.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 59fac9c0c..215b76488 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -1224,11 +1224,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();