chiark / gitweb /
core: inherit TERM from PID 1 for all services started on /dev/console
[elogind.git] / src / basic / terminal-util.c
index 0659310a743b92a759c1a1743d8720c746982f0f..0f2cde00617b613ebdcc9cc38902a10424084366 100644 (file)
@@ -792,7 +792,7 @@ bool tty_is_vc_resolve(const char *tty) {
 }
 
 const char *default_term_for_tty(const char *tty) {
-        return tty && tty_is_vc_resolve(tty) ? "TERM=linux" : "TERM=vt220";
+        return tty && tty_is_vc_resolve(tty) ? "linux" : "vt220";
 }
 #endif // 0
 
@@ -1203,9 +1203,12 @@ int open_terminal_in_namespace(pid_t pid, const char *name, int mode) {
 }
 #endif // 0
 
-static bool getenv_terminal_is_dumb(void) {
+bool terminal_is_dumb(void) {
         const char *e;
 
+        if (!on_tty())
+                return true;
+
         e = getenv("TERM");
         if (!e)
                 return true;
@@ -1213,13 +1216,6 @@ static bool getenv_terminal_is_dumb(void) {
         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;
 
@@ -1229,9 +1225,6 @@ bool colors_enabled(void) {
                 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();
         }