From: Mike Yuan Date: Wed, 28 May 2025 18:40:33 +0000 (+0200) Subject: core/exec-invoke: propagate $COLORTERM and $NO_COLOR from pid1 as well X-Git-Tag: v258-rc1~443^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8ffebaaf4d25ad72df47d1418f01b27b8321811f;p=thirdparty%2Fsystemd.git core/exec-invoke: propagate $COLORTERM and $NO_COLOR from pid1 as well Follow-up for 19aff5f775386a34224f710b88457c1e6bdf0e2f --- diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c index bfa21474e17..2e96bf2eb72 100644 --- a/src/core/exec-invoke.c +++ b/src/core/exec-invoke.c @@ -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; } }