chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
elogind: ignore lack of tty when checking whether colors should be enabled
[elogind.git]
/
src
/
basic
/
terminal-util.c
diff --git
a/src/basic/terminal-util.c
b/src/basic/terminal-util.c
index 465326cfcf1845fc808a9222b76986e2010e2bb0..0659310a743b92a759c1a1743d8720c746982f0f 100644
(file)
--- a/
src/basic/terminal-util.c
+++ b/
src/basic/terminal-util.c
@@
-1203,12
+1203,9
@@
int open_terminal_in_namespace(pid_t pid, const char *name, int mode) {
}
#endif // 0
}
#endif // 0
-
bool
terminal_is_dumb(void) {
+
static bool getenv_
terminal_is_dumb(void) {
const char *e;
const char *e;
- if (!on_tty())
- return true;
-
e = getenv("TERM");
if (!e)
return true;
e = getenv("TERM");
if (!e)
return true;
@@
-1216,6
+1213,13
@@
bool terminal_is_dumb(void) {
return streq(e, "dumb");
}
return streq(e, "dumb");
}
+bool terminal_is_dumb(void) {
+ if (!on_tty())
+ return true;
+
+ return getenv_terminal_is_dumb();
+}
+
bool colors_enabled(void) {
static int enabled = -1;
bool colors_enabled(void) {
static int enabled = -1;
@@
-1225,6
+1229,9
@@
bool colors_enabled(void) {
colors = getenv("SYSTEMD_COLORS");
if (colors)
enabled = parse_boolean(colors) != 0;
colors = getenv("SYSTEMD_COLORS");
if (colors)
enabled = parse_boolean(colors) != 0;
+ else if (getpid() == 1)
+ /* PID1 outputs to the console without holding it open all the time */
+ enabled = !getenv_terminal_is_dumb();
else
enabled = !terminal_is_dumb();
}
else
enabled = !terminal_is_dumb();
}