]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/exec-invoke: propagate $COLORTERM and $NO_COLOR from pid1 as well
authorMike Yuan <me@yhndnzj.com>
Wed, 28 May 2025 18:40:33 +0000 (20:40 +0200)
committerMike Yuan <me@yhndnzj.com>
Thu, 29 May 2025 19:16:28 +0000 (21:16 +0200)
Follow-up for 19aff5f775386a34224f710b88457c1e6bdf0e2f

src/core/exec-invoke.c

index bfa21474e1759b6002044e7424f223ebf4a19d88..2e96bf2eb72f463a92410b7a55791910937da307 100644 (file)
@@ -4548,6 +4548,16 @@ static int setup_term_environment(const ExecContext *context, char ***env) {
                                 if (r < 0)
                                         return r;
 
+                                FOREACH_STRING(i, "COLORTERM=", "NO_COLOR=") {
+                                        const char *s = strv_find_prefix(environ, i);
+                                        if (!s)
+                                                continue;
+
+                                        r = strv_env_replace_strdup(env, s);
+                                        if (r < 0)
+                                                return r;
+                                }
+
                                 return 1;
                         }
                 }