basic: do not output emojis if not on a proper terminal

$TERM would generally be set if we're connected to a proper graphical terminal
emulator. In all other cases, in particular if $TERM is not set, we almost
certainly are not connected to something that can output emojis. In particular
the text console is unlikely to ever do it correctly.

So let's invert the check, and only write emojis if $TERM is set.

Fixes #25521.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-12-14 15:39:26 +01:00 committed by Yu Watanabe
parent 60e84f0205
commit 7a14db9cfd

View file

@ -9,15 +9,15 @@ bool emoji_enabled(void) {
static int cached_emoji_enabled = -1;
if (cached_emoji_enabled < 0) {
int val;
int val = getenv_bool("SYSTEMD_EMOJI");
if (val >= 0)
return (cached_emoji_enabled = val);
val = getenv_bool("SYSTEMD_EMOJI");
if (val < 0)
cached_emoji_enabled =
is_locale_utf8() &&
!STRPTR_IN_SET(getenv("TERM"), "dumb", "linux");
else
cached_emoji_enabled = val;
const char *term = getenv("TERM");
if (!term || STR_IN_SET(term, "dumb", "linux"))
return (cached_emoji_enabled = false);
cached_emoji_enabled = is_locale_utf8();
}
return cached_emoji_enabled;